From a50beb14d36efe46cf7cc4d2c44724d58edb6392 Mon Sep 17 00:00:00 2001 From: MOHANKUMAR T <31698165+mohan-13@users.noreply.github.com> Date: Tue, 27 Aug 2024 06:22:53 +0530 Subject: [PATCH] BAH-4090 | Add. Workflow torelease artifacts on push of a tag (#276) --- .github/workflows/build_publish.yml | 9 ++++-- .github/workflows/release_deploy.yml | 44 ++++++++++++++++++++++++++++ pom.xml | 7 +++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release_deploy.yml diff --git a/.github/workflows/build_publish.yml b/.github/workflows/build_publish.yml index 38070da90..4a3166bd9 100644 --- a/.github/workflows/build_publish.yml +++ b/.github/workflows/build_publish.yml @@ -32,8 +32,13 @@ jobs: run: | sudo gem install compass -v 1.0.3 - name: Build and deploy with Maven - run: ./mvnw --no-transfer-progress clean -U deploy + run: | + PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) + if [[ "$PROJECT_VERSION" == *"-SNAPSHOT" ]]; then + ./mvnw --no-transfer-progress clean -U deploy + else + echo "❌ The current push is for release. So skipping build." + fi env: NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - diff --git a/.github/workflows/release_deploy.yml b/.github/workflows/release_deploy.yml new file mode 100644 index 000000000..4388e9502 --- /dev/null +++ b/.github/workflows/release_deploy.yml @@ -0,0 +1,44 @@ +name: Build and Release package +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +jobs: + build-release-package: + name: Build and Release package + runs-on: macos-14 + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + server-id: nexus-sonatype + server-username: NEXUS_USERNAME + server-password: NEXUS_PASSWORD + gpg-private-key: ${{ secrets.BAHMNI_INFRA_GPG_KEY }} + - name: Compare Git tag with Maven version + run: | + export GIT_TAG=${GITHUB_REF#refs/tags/} + PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) + if [ "$PROJECT_VERSION" != "$GIT_TAG" ]; then + echo "❌ The Git tag ($GIT_TAG) does not match the Maven version ($PROJECT_VERSION)." + exit 1 + else + echo "✅ The Git tag matches the Maven version." + fi + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + bundler-cache: true + - name: Install compass + run: | + sudo gem install compass -v 1.0.3 + - name: Build and deploy with Maven + run: ./mvnw --no-transfer-progress clean -U deploy -DperformRelease=true + env: + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.BAHMNI_INFRA_GPG_PASSPHRASE }} diff --git a/pom.xml b/pom.xml index 28710b360..fa9708e9c 100644 --- a/pom.xml +++ b/pom.xml @@ -155,6 +155,13 @@ org.apache.maven.plugins maven-gpg-plugin 1.6 + + + + --pinentry-mode + loopback + + sign-artifacts