Skip to content

Commit 81a836d

Browse files
authored
Merge pull request #363 from digipost/upgrade-maven-central-deploy-with-new-plugin
Upgrade deployment to Maven Central to use new plugin from Sonatype
2 parents b0419db + e2cc78c commit 81a836d

File tree

5 files changed

+43
-50
lines changed

5 files changed

+43
-50
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,51 @@ jobs:
1111

1212
name: build java ${{ matrix.java }}
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1515
- name: Set up java
16-
uses: actions/setup-java@v3.6.0
16+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
1717
with:
1818
java-version: ${{ matrix.java }}
1919
distribution: temurin
2020
cache: "maven"
2121
- name: Build with Maven
2222
run: mvn --settings .mvn/settings.xml -B verify -U --no-transfer-progress
2323

24-
makeversion:
25-
if: github.ref != 'refs/heads/main'
24+
publish:
2625
needs: build
26+
name: Publish ${{ github.ref_name }}
2727
runs-on: ubuntu-latest
28-
name: Create version
29-
outputs:
30-
version: ${{ steps.version.outputs.version }}
3128
steps:
32-
- name: Decide on build version
33-
id: version
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
- name: Set up Java
31+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
32+
with:
33+
distribution: temurin
34+
java-version: '8'
35+
cache: "maven"
36+
gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }}
37+
server-id: central
38+
server-username: MAVEN_CENTRAL_TOKEN_USERNAME
39+
server-password: MAVEN_CENTRAL_TOKEN_PASSWORD
40+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
41+
- name: Activate Artifact Signing and Version Suffix
3442
run: |
35-
if [[ $GITHUB_REF == *"tags"* ]]; then
36-
TAG=${GITHUB_REF#refs/tags/}
43+
profiles="build-sources-and-javadoc,deploy-to-maven-central"
44+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
45+
profiles="$profiles,sign-artifacts"
46+
version_suffix=""
3747
else
38-
TAG=${GITHUB_REF#refs/heads/}-SNAPSHOT
48+
version_suffix="-SNAPSHOT"
3949
fi
40-
echo "version=${TAG//\//-}" >> $GITHUB_OUTPUT
41-
42-
deploy_snapshot:
43-
if: startsWith(github.ref, 'refs/heads/')
44-
needs: makeversion
45-
runs-on: ubuntu-latest
46-
47-
name: Deploy snapshot
48-
steps:
49-
- uses: actions/checkout@v3
50-
- uses: digipost/[email protected]
51-
with:
52-
sonatype_secrets: ${{ secrets.sonatype_secrets }}
53-
release_version: ${{ needs.makeversion.outputs.version }}
54-
perform_release: false
55-
56-
release:
57-
if: startsWith(github.ref, 'refs/tags/')
58-
runs-on: ubuntu-latest
59-
needs: makeversion
60-
name: Release to Sonatype
61-
steps:
62-
- name: Check out Git repository
63-
uses: actions/checkout@v3
64-
- name: Release to Central Repository
65-
uses: digipost/[email protected]
66-
with:
67-
sonatype_secrets: ${{ secrets.sonatype_secrets }}
68-
release_version: ${{ needs.makeversion.outputs.version }}
69-
perform_release: true
50+
echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV
51+
version="${GITHUB_REF_NAME}${version_suffix}"
52+
echo "VERSION=$version" >> $GITHUB_ENV
53+
- name: Set Maven version
54+
run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION}
55+
- name: Build and deploy to Maven Central
56+
run: |
57+
mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy
58+
env:
59+
MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
60+
MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
61+
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
.classpath
88

99
dependency-reduced-pom.xml
10+
.vscode/settings.json

bom/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
<name>Posten signering - Java API Client BOM</name>
3131

3232
<properties>
33-
<signature.api.version>3.1.0</signature.api.version>
33+
<signature.api.version>3.1.1</signature.api.version>
3434
</properties>
3535

3636
<dependencyManagement>
3737
<dependencies>
3838
<dependency>
3939
<groupId>no.digipost</groupId>
4040
<artifactId>jaxb-resolver-com.sun.xml.bind-bom</artifactId>
41-
<version>1.0</version>
41+
<version>1.0.1</version>
4242
<type>pom</type>
4343
<scope>import</scope>
4444
</dependency>

lib/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<dependency>
6363
<groupId>no.digipost</groupId>
6464
<artifactId>certificate-validator</artifactId>
65-
<version>3.0.5</version>
65+
<version>3.0.6</version>
6666
<exclusions>
6767
<exclusion>
6868
<groupId>org.bouncycastle</groupId>
@@ -148,7 +148,7 @@
148148
<dependency>
149149
<groupId>no.digipost</groupId>
150150
<artifactId>digg</artifactId>
151-
<version>0.37</version>
151+
<version>0.38</version>
152152
<scope>test</scope>
153153
</dependency>
154154

@@ -167,7 +167,7 @@
167167
<dependency>
168168
<groupId>no.digipost</groupId>
169169
<artifactId>jul-to-slf4j-junit-extension</artifactId>
170-
<version>1.0.1</version>
170+
<version>1.0.2</version>
171171
<scope>test</scope>
172172
</dependency>
173173
</dependencies>
@@ -244,7 +244,7 @@
244244
</plugin>
245245
<plugin>
246246
<artifactId>maven-enforcer-plugin</artifactId>
247-
<version>3.5.0</version>
247+
<version>3.6.1</version>
248248
<configuration>
249249
<rules>
250250
<bannedDependencies>

pom.xml

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

2828
<groupId>no.digipost.signature</groupId>
@@ -54,7 +54,7 @@
5454
</plugin>
5555
<plugin>
5656
<artifactId>maven-clean-plugin</artifactId>
57-
<version>3.4.1</version>
57+
<version>3.5.0</version>
5858
<configuration>
5959
<filesets>
6060
<fileset>

0 commit comments

Comments
 (0)