Skip to content

Commit 295f37e

Browse files
authored
Merge pull request #200 from digipost/upgrade-maven-central-deploy-with-new-plugin
Upgrade deployment to Maven Central to use new plugin from Sonatype
2 parents 4d03942 + 6fc338a commit 295f37e

3 files changed

Lines changed: 53 additions & 48 deletions

File tree

.github/workflows/build.yml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,50 @@ jobs:
1010
name: Build on Java ${{ matrix.java }}
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
14-
- uses: actions/setup-java@v3
13+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
14+
- uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
1515
with:
1616
distribution: temurin
1717
java-version: ${{ matrix.java }}
1818
cache: "maven"
1919
- name: Build with Maven
2020
run: mvn -B -U verify --no-transfer-progress --show-version --settings .mvn/settings.xml
2121

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ target
77
*.iml
88
.idea
99
.sonatype
10+
.vscode/settings.json

pom.xml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>no.digipost</groupId>
77
<artifactId>digipost-open-super-pom</artifactId>
8-
<version>13</version>
8+
<version>14</version>
99
</parent>
1010

1111
<artifactId>digipost-api-client-java</artifactId>
@@ -41,17 +41,17 @@
4141
<dependency>
4242
<groupId>no.digipost</groupId>
4343
<artifactId>printability-validator</artifactId>
44-
<version>3.5.1</version>
44+
<version>3.5.3</version>
4545
</dependency>
4646
<dependency>
4747
<groupId>no.digipost</groupId>
4848
<artifactId>digipost-html-validator</artifactId>
49-
<version>1.1.0</version>
49+
<version>1.1.1</version>
5050
</dependency>
5151
<dependency>
5252
<groupId>no.digipost</groupId>
5353
<artifactId>digipost-cache</artifactId>
54-
<version>2.0.2</version>
54+
<version>2.0.3</version>
5555
</dependency>
5656
<dependency>
5757
<groupId>org.slf4j</groupId>
@@ -166,13 +166,13 @@
166166
<dependency>
167167
<groupId>no.digipost</groupId>
168168
<artifactId>digg</artifactId>
169-
<version>0.37</version>
169+
<version>0.38</version>
170170
<scope>test</scope>
171171
</dependency>
172172
<dependency>
173173
<groupId>no.digipost</groupId>
174174
<artifactId>digipost-data-types</artifactId>
175-
<version>1.1.0</version>
175+
<version>1.2.2</version>
176176
</dependency>
177177
<dependency>
178178
<groupId>org.glassfish.jaxb</groupId>
@@ -254,35 +254,35 @@
254254
<plugins>
255255
<plugin>
256256
<artifactId>maven-compiler-plugin</artifactId>
257-
<version>3.13.0</version>
257+
<version>3.14.0</version>
258258
</plugin>
259259
<plugin>
260260
<artifactId>maven-surefire-plugin</artifactId>
261-
<version>3.2.5</version>
261+
<version>3.5.3</version>
262262
</plugin>
263263
<plugin>
264264
<artifactId>maven-source-plugin</artifactId>
265265
<version>3.3.1</version>
266266
</plugin>
267267
<plugin>
268268
<artifactId>maven-javadoc-plugin</artifactId>
269-
<version>3.6.3</version>
269+
<version>3.11.2</version>
270270
</plugin>
271271
<plugin>
272272
<artifactId>maven-deploy-plugin</artifactId>
273-
<version>3.1.2</version>
273+
<version>3.1.4</version>
274274
</plugin>
275275
<plugin>
276276
<artifactId>maven-clean-plugin</artifactId>
277-
<version>3.3.2</version>
277+
<version>3.5.0</version>
278278
</plugin>
279279
<plugin>
280280
<artifactId>maven-dependency-plugin</artifactId>
281-
<version>3.6.1</version>
281+
<version>3.8.1</version>
282282
</plugin>
283283
<plugin>
284284
<artifactId>maven-jar-plugin</artifactId>
285-
<version>3.4.1</version>
285+
<version>3.4.2</version>
286286
<configuration>
287287
<archive>
288288
<manifest>
@@ -294,25 +294,25 @@
294294
</plugin>
295295
<plugin>
296296
<artifactId>maven-install-plugin</artifactId>
297-
<version>3.1.2</version>
297+
<version>3.1.4</version>
298298
</plugin>
299299
<plugin>
300300
<artifactId>maven-resources-plugin</artifactId>
301301
<version>3.3.1</version>
302302
</plugin>
303303
<plugin>
304304
<artifactId>maven-enforcer-plugin</artifactId>
305-
<version>3.4.1</version>
305+
<version>3.6.1</version>
306306
</plugin>
307307
<plugin>
308308
<groupId>org.codehaus.mojo</groupId>
309309
<artifactId>versions-maven-plugin</artifactId>
310-
<version>2.16.2</version>
310+
<version>2.18.0</version>
311311
</plugin>
312312
<plugin>
313313
<groupId>com.github.siom79.japicmp</groupId>
314314
<artifactId>japicmp-maven-plugin</artifactId>
315-
<version>0.21.1</version>
315+
<version>0.23.1</version>
316316
<configuration>
317317
<parameter>
318318
<includes>
@@ -327,7 +327,7 @@
327327
<plugin>
328328
<groupId>com.mycila</groupId>
329329
<artifactId>license-maven-plugin</artifactId>
330-
<version>4.3</version>
330+
<version>5.0.0</version>
331331
<configuration>
332332
<licenseSets>
333333
<licenseSet>

0 commit comments

Comments
 (0)