From 74774817f504a0af1b165aeb221be5b330b4095c Mon Sep 17 00:00:00 2001 From: Pasindu Owa Gamage Date: Sat, 21 Feb 2026 17:51:49 +0530 Subject: [PATCH 1/3] Created Build with Maven workflow for CI --- .github/workflows/build.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..db8c379 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Java CI with Maven + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: mvn -B clean install --file pom.xml \ No newline at end of file From 2abfe073410765be925c56a3eff312111896536a Mon Sep 17 00:00:00 2001 From: Pasindu Owa Gamage Date: Sat, 21 Feb 2026 18:29:27 +0530 Subject: [PATCH 2/3] Setup repository secrets to build file --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db8c379..8c8fdea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,10 @@ jobs: java-version: '17' distribution: 'temurin' cache: maven + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE - name: Build with Maven + env: + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} run: mvn -B clean install --file pom.xml \ No newline at end of file From d9a8b561a969b015e10f9a630faf240d94038ba7 Mon Sep 17 00:00:00 2001 From: Pasindu Owa Gamage Date: Sat, 21 Feb 2026 19:17:03 +0530 Subject: [PATCH 3/3] Completed CI/CD Pipeline workflow --- .github/workflows/build.yml | 67 +++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c8fdea..75dd3b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Java CI with Maven +name: Java CI/CD with Maven on: push: @@ -19,11 +19,72 @@ jobs: with: java-version: '17' distribution: 'temurin' - cache: maven + server-id: central + server-username: ${{ secrets.MAVEN_USERNAME }} + server-password: ${{ secrets.MAVEN_PASSWORD }} gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} gpg-passphrase: MAVEN_GPG_PASSPHRASE - name: Build with Maven env: MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - run: mvn -B clean install --file pom.xml \ No newline at end of file + run: mvn -B clean install --file pom.xml + + publish: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + server-id: central + server-username: ${{ secrets.MAVEN_USERNAME }} + server-password: ${{ secrets.MAVEN_PASSWORD }} + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} + + - name: Get Project Version + id: get_version + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "VERSION is $VERSION" + + - name: Check if Tag Exists + id: check_tag + run: | + if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then + echo "EXISTS=true" >> $GITHUB_ENV + echo "Tag v${{ env.VERSION }} already exists. Skipping release." + else + echo "EXISTS=false" >> $GITHUB_ENV + echo "New version detected: v${{ env.VERSION }}" + fi + + - name: Create GitHub Release + if: env.EXISTS == 'false' + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ env.VERSION }} + name: Release v${{ env.VERSION }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Deploy to Maven Central + if: env.EXISTS == 'false' + env: + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: | + mvn deploy + echo "Deploying version ${{ env.VERSION }}..." \ No newline at end of file