From 7ff981d8ca645cfccdb14d7d57f250ad2f79dc8d Mon Sep 17 00:00:00 2001 From: Tihomir Krasimirov Mateev Date: Fri, 7 Jun 2024 21:04:54 +0300 Subject: [PATCH 1/4] Modify the release acrtion to call the proper maven target for release, make releasing manually available too (#2885) --- .github/workflows/version-and-release.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/version-and-release.yaml b/.github/workflows/version-and-release.yaml index 7f0fa2cd74..93ee19348b 100644 --- a/.github/workflows/version-and-release.yaml +++ b/.github/workflows/version-and-release.yaml @@ -2,23 +2,25 @@ name: Release on: release: - types: [published] + types: [published] # once a release is published in the GitHub UI + workflow_dispatch: # or manually, by clicking the button jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: 1. Checkout sources + uses: actions/checkout@v4 - - name: get version from tag + - name: 2. Extract version from tag id: get_version run: | realversion="${GITHUB_REF/refs\/tags\//}" realversion="${realversion//v/}" echo "VERSION=$realversion" >> $GITHUB_OUTPUT - - name: Set up publishing to maven central + - name: 3. Set up Java with Maven cache uses: actions/setup-java@v4 with: java-version: '8' @@ -28,20 +30,20 @@ jobs: server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD - - name: mvn versions + - name: 4. Update version in Maven configuration run: mvn versions:set -DnewVersion=${{ steps.get_version.outputs.VERSION }} - - name: Install gpg key + - name: 5. Install GPG key run: | cat <(echo -e "${{ secrets.OSSH_GPG_SECRET_KEY }}") | gpg --batch --import gpg --list-secret-keys --keyid-format LONG - - name: Publish + - name: 6. Publish to Maven run: | mvn --no-transfer-progress \ --batch-mode \ -Dgpg.passphrase='${{ secrets.OSSH_GPG_SECRET_KEY_PASSWORD }}' \ - deploy -P release + release:perform env: MAVEN_USERNAME: ${{secrets.OSSH_USERNAME}} - MAVEN_PASSWORD: ${{secrets.OSSH_TOKEN}} \ No newline at end of file + MAVEN_PASSWORD: ${{secrets.OSSH_TOKEN}} From 9f1ca1cae36491ed12eee972c5d764ff726adaeb Mon Sep 17 00:00:00 2001 From: Tihomir Mateev Date: Tue, 11 Jun 2024 16:29:42 +0300 Subject: [PATCH 2/4] Added the nexus staging plugin --- .github/workflows/version-and-release.yaml | 24 +++++++++------------- pom.xml | 12 +++++++++++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/version-and-release.yaml b/.github/workflows/version-and-release.yaml index 93ee19348b..6fbbb122c8 100644 --- a/.github/workflows/version-and-release.yaml +++ b/.github/workflows/version-and-release.yaml @@ -10,17 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: 1. Checkout sources + - name: Checkout sources uses: actions/checkout@v4 - - name: 2. Extract version from tag - id: get_version - run: | - realversion="${GITHUB_REF/refs\/tags\//}" - realversion="${realversion//v/}" - echo "VERSION=$realversion" >> $GITHUB_OUTPUT - - - name: 3. Set up Java with Maven cache + - name: Set up Java with Maven cache uses: actions/setup-java@v4 with: java-version: '8' @@ -30,20 +23,23 @@ jobs: server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD - - name: 4. Update version in Maven configuration - run: mvn versions:set -DnewVersion=${{ steps.get_version.outputs.VERSION }} + - name: Update version in Maven configuration + run: | + mvn --no-transfer-progress \ + --batch-mode \ + versions:set -DnewVersion=${{ github.event.release.tag_name }} - - name: 5. Install GPG key + - name: Install GPG key run: | cat <(echo -e "${{ secrets.OSSH_GPG_SECRET_KEY }}") | gpg --batch --import gpg --list-secret-keys --keyid-format LONG - - name: 6. Publish to Maven + - name: Publish to Maven run: | mvn --no-transfer-progress \ --batch-mode \ -Dgpg.passphrase='${{ secrets.OSSH_GPG_SECRET_KEY_PASSWORD }}' \ - release:perform + deploy -P sonatype-oss-release env: MAVEN_USERNAME: ${{secrets.OSSH_USERNAME}} MAVEN_PASSWORD: ${{secrets.OSSH_TOKEN}} diff --git a/pom.xml b/pom.xml index 9be9d982f7..a2642124ab 100644 --- a/pom.xml +++ b/pom.xml @@ -604,6 +604,18 @@ 3.0.1 + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://oss.sonatype.org/ + true + + + org.apache.maven.plugins maven-surefire-plugin From b1a11977b0d37b78364f5d79c631bc6abc2fa2ce Mon Sep 17 00:00:00 2001 From: Tihomir Mateev Date: Tue, 11 Jun 2024 16:46:52 +0300 Subject: [PATCH 3/4] Make version step conditional on the availability of a tag name in the event --- .github/workflows/version-and-release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/version-and-release.yaml b/.github/workflows/version-and-release.yaml index 6fbbb122c8..ea2970331e 100644 --- a/.github/workflows/version-and-release.yaml +++ b/.github/workflows/version-and-release.yaml @@ -28,6 +28,7 @@ jobs: mvn --no-transfer-progress \ --batch-mode \ versions:set -DnewVersion=${{ github.event.release.tag_name }} + if: ${{ github.event.release.tag_name }} - name: Install GPG key run: | From dd08e6fff275492a10256a95c81968ed97aab138 Mon Sep 17 00:00:00 2001 From: Tihomir Mateev Date: Tue, 11 Jun 2024 17:08:51 +0300 Subject: [PATCH 4/4] Missed the GPG configuration --- pom.xml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index a2642124ab..793c3b2446 100644 --- a/pom.xml +++ b/pom.xml @@ -604,18 +604,6 @@ 3.0.1 - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 - true - - ossrh - https://oss.sonatype.org/ - true - - - org.apache.maven.plugins maven-surefire-plugin @@ -912,6 +900,18 @@ + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://oss.sonatype.org/ + true + + + org.apache.maven.plugins maven-source-plugin @@ -1031,6 +1031,12 @@ org.apache.maven.plugins maven-gpg-plugin + + + --pinentry-mode + loopback + + sign-artifacts