Skip to content

Commit 978685d

Browse files
authored
improve: migrate to new maven release plugin (#241)
Signed-off-by: Attila Mészáros <[email protected]>
1 parent 85ea04d commit 978685d

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

.github/workflows/master-snapshot-release.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ jobs:
3737
- name: Set up Java and Maven
3838
uses: actions/setup-java@v4
3939
with:
40-
distribution: temurin
4140
java-version: 17
41+
distribution: temurin
4242
cache: 'maven'
43-
- name: Release Maven package
44-
uses: samuelmeuli/action-maven-publish@v1
45-
with:
46-
maven_profiles: "release"
47-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
48-
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
49-
nexus_username: ${{ secrets.OSSRH_USERNAME }}
50-
nexus_password: ${{ secrets.OSSRH_TOKEN }}
43+
server-id: central
44+
server-username: MAVEN_USERNAME
45+
server-password: MAVEN_CENTRAL_TOKEN
46+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
47+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
48+
49+
- name: Publish to Apache Maven Central
50+
run: mvn package deploy -Prelease
51+
env:
52+
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
53+
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PASSWORD }}
54+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/release.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,25 @@ jobs:
1515
java-version: 17
1616
distribution: temurin
1717
cache: 'maven'
18+
server-id: central
19+
server-username: MAVEN_USERNAME
20+
server-password: MAVEN_CENTRAL_TOKEN
21+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
22+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
23+
1824
- name: change version to release version
1925
# Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
2026
run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
2127
env:
2228
RELEASE_VERSION: ${{ github.event.release.tag_name }}
23-
- name: Release Maven package
24-
uses: samuelmeuli/action-maven-publish@v1
25-
with:
26-
maven_profiles: "release"
27-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
28-
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
29-
nexus_username: ${{ secrets.OSSRH_USERNAME }}
30-
nexus_password: ${{ secrets.OSSRH_TOKEN }}
29+
30+
- name: Publish to Apache Maven Central
31+
run: mvn package deploy -Prelease
32+
env:
33+
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
34+
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PASSWORD }}
35+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
36+
3137

3238
# This is separate job because there were issues with git after release step, was not able to commit changes. See history.
3339
update-working-version:

pom.xml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@
4444
<url>https://github.com/java-operator-sdk/operator-framework-spring-boot-starter.git/tree/master</url>
4545
</scm>
4646

47-
<distributionManagement>
48-
<snapshotRepository>
49-
<id>ossrh</id>
50-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
51-
</snapshotRepository>
52-
</distributionManagement>
53-
5447
<properties>
5548
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5649
<java.version>17</java.version>
@@ -67,6 +60,7 @@
6760
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
6861
<maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
6962
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
63+
<central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
7064
</properties>
7165

7266
<dependencyManagement>
@@ -238,14 +232,15 @@
238232
</executions>
239233
</plugin>
240234
<plugin>
241-
<groupId>org.sonatype.plugins</groupId>
242-
<artifactId>nexus-staging-maven-plugin</artifactId>
243-
<version>${nexus-staging-maven-plugin.version}</version>
235+
<groupId>org.sonatype.central</groupId>
236+
<artifactId>central-publishing-maven-plugin</artifactId>
237+
<version>${central-publishing-maven-plugin.version}</version>
244238
<extensions>true</extensions>
245239
<configuration>
246-
<serverId>ossrh</serverId>
247-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
248-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
240+
<publishingServerId>central</publishingServerId>
241+
<tokenAuth>true</tokenAuth>
242+
<autoPublish>true</autoPublish>
243+
<waitUntil>published</waitUntil>
249244
</configuration>
250245
</plugin>
251246
</plugins>

0 commit comments

Comments
 (0)