Skip to content

Commit 7484ecd

Browse files
authored
Merge pull request #323 from digipost/upgrade-maven-central-deploy-with-new-plugin
Upgrade sonatype plugin and bump super-pom to 14
2 parents 0b146da + b83fea4 commit 7484ecd

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,41 @@ jobs:
2222
run: mvn verify
2323

2424

25-
publishing_parameters:
25+
publish:
2626
needs: build
27-
name: Publishing parameters
27+
name: Publish ${{ github.ref_name }}
2828
runs-on: ubuntu-latest
29-
outputs:
30-
is_release: ${{ steps.version.outputs.is_release }}
31-
version: ${{ steps.version.outputs.version }}
3229
steps:
33-
- name: Determine version
34-
id: version
30+
- uses: actions/[email protected]
31+
- name: Set up Java
32+
uses: actions/[email protected]
33+
with:
34+
distribution: temurin
35+
java-version: '21'
36+
cache: "maven"
37+
gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }}
38+
server-id: central
39+
server-username: MAVEN_CENTRAL_TOKEN_USERNAME
40+
server-password: MAVEN_CENTRAL_TOKEN_PASSWORD
41+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
42+
- name: Activate Artifact Signing and Version Suffix
3543
run: |
36-
if [[ $GITHUB_REF == *"tags"* ]]; then
37-
is_release=true
38-
version=${GITHUB_REF#refs/tags/}
44+
profiles="build-sources-and-javadoc,deploy-to-maven-central"
45+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
46+
profiles="$profiles,sign-artifacts"
47+
version_suffix=""
3948
else
40-
is_release=false
41-
version=${GITHUB_REF#refs/heads/}-SNAPSHOT
49+
version_suffix="-SNAPSHOT"
4250
fi
43-
echo "is_release=${is_release//\//-}" >> $GITHUB_OUTPUT
44-
echo "version=${version//\//-}" >> $GITHUB_OUTPUT
45-
46-
47-
publish:
48-
needs: publishing_parameters
49-
name: Publish ${{ needs.publishing_parameters.outputs.version }}
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v3
53-
- uses: digipost/action-maven-publish@v1
54-
with:
55-
sonatype_secrets: ${{ secrets.sonatype_secrets }}
56-
release_version: ${{ needs.publishing_parameters.outputs.version }}
57-
perform_release: ${{ needs.publishing_parameters.outputs.is_release }}
51+
echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV
52+
version="${GITHUB_REF_NAME}${version_suffix}"
53+
echo "VERSION=$version" >> $GITHUB_ENV
54+
- name: Set Maven version
55+
run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION}
56+
- name: Build and deploy to Maven Central
57+
run: |
58+
mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy
59+
env:
60+
MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
61+
MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
62+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSPHRASE }}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>no.digipost</groupId>
2525
<artifactId>digipost-open-super-pom</artifactId>
26-
<version>13</version>
26+
<version>14</version>
2727
</parent>
2828

2929
<name>Posten signering - API Specification</name>
@@ -102,7 +102,7 @@
102102
</plugin>
103103
<plugin>
104104
<artifactId>maven-deploy-plugin</artifactId>
105-
<version>3.1.1</version>
105+
<version>3.1.4</version>
106106
</plugin>
107107
<plugin>
108108
<artifactId>maven-antrun-plugin</artifactId>

0 commit comments

Comments
 (0)