From ed81b7bacbc11d2f28e39a5e5e5937dd7aa73a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20=C3=98ien=20Lunde?= Date: Fri, 8 Aug 2025 13:26:09 +0200 Subject: [PATCH 1/2] Upgrade deployment to Maven Central to use new plugin from Sonatype Rewrite the publishing job to deploy directly to Maven Central (was: using obsolete GitHub action) with new plugin configured in the parent POM and using more recent support in setup-java for deployment settings in Maven. --- .github/workflows/build.yml | 66 ++++++++++++++++++++----------------- pom.xml | 2 +- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b165e0..9e7b94f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,46 +10,50 @@ jobs: name: Build on Java ${{ matrix.java }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 with: distribution: temurin java-version: ${{ matrix.java }} cache: "maven" - name: Build with Maven - run: mvn -B clean verify --no-transfer-progress --show-version + run: mvn -B verify --no-transfer-progress --show-version - - publishing_parameters: + publish: needs: build - name: Publishing parameters + name: Publish ${{ github.ref_name }} runs-on: ubuntu-latest - outputs: - is_release: ${{ steps.version.outputs.is_release }} - version: ${{ steps.version.outputs.version }} steps: - - name: Determine version - id: version + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Set up Java + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 + with: + distribution: temurin + java-version: '21' + cache: "maven" + gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }} + server-id: central + server-username: MAVEN_CENTRAL_TOKEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN_PASSWORD + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Activate Artifact Signing and Version Suffix run: | - if [[ $GITHUB_REF == *"tags"* ]]; then - is_release=true - version=${GITHUB_REF#refs/tags/} + profiles="build-sources-and-javadoc,deploy-to-maven-central" + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then + profiles="$profiles,sign-artifacts" + version_suffix="" else - is_release=false - version=${GITHUB_REF#refs/heads/}-SNAPSHOT + version_suffix="-SNAPSHOT" fi - echo "is_release=${is_release//\//-}" >> $GITHUB_OUTPUT - echo "version=${version//\//-}" >> $GITHUB_OUTPUT - - - publish: - needs: publishing_parameters - name: Publish ${{ needs.publishing_parameters.outputs.version }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: digipost/action-maven-publish@v1 - with: - sonatype_secrets: ${{ secrets.sonatype_secrets }} - release_version: ${{ needs.publishing_parameters.outputs.version }} - perform_release: ${{ needs.publishing_parameters.outputs.is_release }} + echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV + version="${GITHUB_REF_NAME}${version_suffix}" + echo "VERSION=$version" >> $GITHUB_ENV + - name: Set Maven version + run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION} + - name: Build and deploy to Maven Central + run: | + mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy + env: + MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }} + MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSPHRASE }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 12cd570..4904162 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ no.digipost digipost-open-super-pom - 13 + 14 certificate-validator From 108cce3a4b1ca6f3f87e109789e671cc8b92c0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20=C3=98ien=20Lunde?= Date: Fri, 8 Aug 2025 13:29:00 +0200 Subject: [PATCH 2/2] Use java version 17 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e7b94f..24ebfcb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 with: distribution: temurin - java-version: '21' + java-version: '17' cache: "maven" gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }} server-id: central