Skip to content

Commit 3287aec

Browse files
committed
👷 Migrate to Maven central for publishing artefacts
This also creates release on github when tag "release/*" is pushed Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
1 parent 686a27b commit 3287aec

3 files changed

Lines changed: 36 additions & 64 deletions

File tree

‎.github/release-drafter.yml‎

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
---
2-
name: Publish package to the Maven Central Repository
2+
name: Publish package to the Maven Central
33
on:
4-
release:
5-
types: [created]
4+
push:
5+
tags:
6+
- release/*
7+
workflow_dispatch:
68
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: softprops/action-gh-release@v2
14+
with:
15+
generate_release_notes: true
716
publish:
817
runs-on: ubuntu-latest
918
steps:
1019
- uses: actions/checkout@v5
1120

12-
- name: Install gpg secret key
13-
run: |
14-
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
15-
gpg --list-secret-keys --keyid-format LONG
16-
1721
- name: Set up Maven Central Repository
1822
uses: actions/setup-java@v4
1923
with:
20-
java-version: '11'
24+
java-version: '17'
2125
distribution: 'adopt'
22-
server-id: ossrh
26+
server-id: central
2327
server-username: MAVEN_USERNAME
2428
server-password: MAVEN_PASSWORD
29+
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
2530
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2631
- name: Publish package
27-
run: mvn --no-transfer-progress --batch-mode deploy -Prelease
32+
run: mvn -DskipTests --no-transfer-progress --batch-mode deploy -Prelease
2833
env:
2934
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
30-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
35+
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_TOKEN }}
3136
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}

‎pom.xml‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@
4646
<tag>main</tag>
4747
<url>https://github.com/dNationCloud/hetzner-cloud-client-java</url>
4848
</scm>
49-
<distributionManagement>
50-
<repository>
51-
<id>ossrh</id>
52-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
53-
</repository>
54-
<snapshotRepository>
55-
<id>ossrh</id>
56-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
57-
</snapshotRepository>
58-
</distributionManagement>
5949
<properties>
6050
<maven.compiler.source>1.8</maven.compiler.source>
6151
<maven.compiler.target>1.8</maven.compiler.target>
@@ -234,6 +224,18 @@
234224
<activation>
235225
<activeByDefault>false</activeByDefault>
236226
</activation>
227+
<distributionManagement>
228+
<repository>
229+
<id>central</id>
230+
<name>Maven Central Releases</name>
231+
<url>https://central.sonatype.com/api/v1/publisher/deploy</url>
232+
</repository>
233+
<snapshotRepository>
234+
<id>central</id>
235+
<name>Maven Central Snapshots</name>
236+
<url>https://central.sonatype.com/api/v1/publisher/snapshots</url>
237+
</snapshotRepository>
238+
</distributionManagement>
237239
<build>
238240
<plugins>
239241
<plugin>
@@ -265,7 +267,7 @@
265267
<plugin>
266268
<groupId>org.apache.maven.plugins</groupId>
267269
<artifactId>maven-gpg-plugin</artifactId>
268-
<version>3.0.1</version>
270+
<version>3.2.4</version>
269271
<executions>
270272
<execution>
271273
<id>sign-artifacts</id>
@@ -274,6 +276,7 @@
274276
</goals>
275277
<phase>verify</phase>
276278
<configuration>
279+
277280
<gpgArguments>
278281
<arg>--pinentry-mode</arg>
279282
<arg>loopback</arg>
@@ -283,14 +286,13 @@
283286
</executions>
284287
</plugin>
285288
<plugin>
286-
<groupId>org.sonatype.plugins</groupId>
287-
<artifactId>nexus-staging-maven-plugin</artifactId>
288-
<version>1.6.7</version>
289+
<groupId>org.sonatype.central</groupId>
290+
<artifactId>central-publishing-maven-plugin</artifactId>
291+
<version>0.8.0</version>
289292
<extensions>true</extensions>
290293
<configuration>
291-
<serverId>ossrh</serverId>
292-
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
293-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
294+
<autoPublish>true</autoPublish>
295+
<publishingServerId>central</publishingServerId>
294296
</configuration>
295297
</plugin>
296298
</plugins>

0 commit comments

Comments
 (0)