From 90d656f1e91758e72a085c802bd4f195375daaa5 Mon Sep 17 00:00:00 2001 From: Ritika Rekhi <143578890+rrekhi1@users.noreply.github.com> Date: Fri, 28 Jun 2024 03:45:45 +0530 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..adf0c49 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,50 @@ +name: Release to Maven Central + +on: + push: + branches: + - main + +jobs: + build-and-release: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Import GPG signing key + uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.MAVEN_SIGNING_KEY }} + passphrase: ${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }} + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '21' + + - name: Calculate version + id: calculate-version + uses: bitshifted/git-auto-semver@v1 + with: + create_tag: true + + - name: Build and Test + run: | + # Replace with your build and test commands + ./mvnw clean verify + + - name: Release to Maven repo + if: success() # Only run if previous steps were successful + run: | + mvn -P release -Dgpg.keyname=${{ secrets.GPG_KEY_NAME }} \ + -Dgpg.passphrase=${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }} \ + -Drevision=${{ steps.calculate-version.outputs.version-string }} deploy + env: + MVN_CENTRAL_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }} + MVN_CENTRAL_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}