Skip to content

Commit 18334ee

Browse files
authored
Merge pull request #17 from digipost/upgrade-maven-central-deploy-with-new-plugin
Upgrade deployment to Maven Central to use new plugin from Sonatype
2 parents 57d8d89 + c0879bb commit 18334ee

File tree

3 files changed

+48
-55
lines changed

3 files changed

+48
-55
lines changed

.github/workflows/build.yml

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

1212
name: build java ${{ matrix.java }}
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1515
- name: Set up java
16-
uses: actions/setup-java@v3
16+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
1717
with:
1818
java-version: ${{ matrix.java }}
1919
distribution: temurin
@@ -23,49 +23,41 @@ jobs:
2323
- name: Build with Maven
2424
run: mvn -B package --no-transfer-progress --file pom.xml
2525

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target/*
22
.idea/*
33
*.iml
4+
.vscode/settings.json

pom.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>no.digipost</groupId>
88
<artifactId>digipost-open-super-pom</artifactId>
9-
<version>6</version>
9+
<version>14</version>
1010
</parent>
1111

1212
<artifactId>digipost-html-validator</artifactId>
@@ -93,19 +93,19 @@
9393
<plugins>
9494
<plugin>
9595
<artifactId>maven-clean-plugin</artifactId>
96-
<version>3.1.0</version>
96+
<version>3.5.0</version>
9797
</plugin>
9898
<plugin>
9999
<artifactId>maven-resources-plugin</artifactId>
100-
<version>3.2.0</version>
100+
<version>3.3.1</version>
101101
</plugin>
102102
<plugin>
103103
<artifactId>maven-compiler-plugin</artifactId>
104-
<version>3.8.1</version>
104+
<version>3.14.0</version>
105105
</plugin>
106106
<plugin>
107107
<artifactId>maven-enforcer-plugin</artifactId>
108-
<version>3.0.0-M3</version>
108+
<version>3.6.1</version>
109109
<configuration>
110110
<rules>
111111
<requireMavenVersion>
@@ -122,38 +122,38 @@
122122
</plugin>
123123
<plugin>
124124
<artifactId>maven-surefire-plugin</artifactId>
125-
<version>3.0.0-M5</version>
125+
<version>3.5.3</version>
126126
</plugin>
127127
<plugin>
128128
<artifactId>maven-dependency-plugin</artifactId>
129-
<version>3.1.1</version>
129+
<version>3.8.1</version>
130130
</plugin>
131131
<plugin>
132132
<artifactId>maven-jar-plugin</artifactId>
133-
<version>3.1.2</version>
133+
<version>3.4.2</version>
134134
</plugin>
135135
<plugin>
136136
<artifactId>maven-install-plugin</artifactId>
137-
<version>3.0.0-M1</version>
137+
<version>3.1.4</version>
138138
</plugin>
139139
<plugin>
140140
<artifactId>maven-deploy-plugin</artifactId>
141-
<version>3.0.0-M1</version>
141+
<version>3.1.4</version>
142142
</plugin>
143143
<plugin>
144144
<groupId>org.codehaus.mojo</groupId>
145145
<artifactId>versions-maven-plugin</artifactId>
146-
<version>2.7</version>
146+
<version>2.18.0</version>
147147
</plugin>
148148
<plugin>
149149
<groupId>org.codehaus.mojo</groupId>
150150
<artifactId>exec-maven-plugin</artifactId>
151-
<version>1.6.0</version>
151+
<version>3.5.1</version>
152152
</plugin>
153153
<plugin>
154154
<groupId>com.github.siom79.japicmp</groupId>
155155
<artifactId>japicmp-maven-plugin</artifactId>
156-
<version>0.14.1</version>
156+
<version>0.23.1</version>
157157
<configuration>
158158
<newVersion>
159159
<file>

0 commit comments

Comments
 (0)