Skip to content

Commit 50a90f1

Browse files
authored
improve: release process (#2861)
see details: https://central.sonatype.org/publish/publish-portal-maven/#usage see sample also here: https://github.com/teamlead/java-maven-sonatype-starter/tree/master Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 07f9935 commit 50a90f1

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

.github/workflows/release-project-in-dir.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ jobs:
2929
java-version: 17
3030
distribution: temurin
3131
cache: 'maven'
32+
server-id: central
33+
server-username: MAVEN_USERNAME
34+
server-password: MAVEN_CENTRAL_TOKEN
35+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
36+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
3237

3338
- name: Change version to release version
3439
# Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
@@ -37,15 +42,12 @@ jobs:
3742
env:
3843
RELEASE_VERSION: ${{ github.event.release.tag_name }}
3944

40-
- name: Release Maven package
41-
uses: samuelmeuli/action-maven-publish@v1
42-
with:
43-
maven_profiles: "release"
44-
maven_args: ${{ env.MAVEN_ARGS }}
45-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
46-
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
47-
nexus_username: ${{ secrets.OSSRH_USERNAME }}
48-
nexus_password: ${{ secrets.OSSRH_TOKEN }}
45+
- name: Publish to Apache Maven Central
46+
run: mvn package deploy -Prelease
47+
env:
48+
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
49+
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PASSWORD }}
50+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
4951

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

.github/workflows/snapshot-releases.yml

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

pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,15 @@
544544
</executions>
545545
</plugin>
546546
<plugin>
547-
<groupId>org.sonatype.plugins</groupId>
548-
<artifactId>nexus-staging-maven-plugin</artifactId>
549-
<version>${nexus-staging-maven-plugin.version}</version>
547+
<groupId>org.sonatype.central</groupId>
548+
<artifactId>central-publishing-maven-plugin</artifactId>
549+
<version>0.8.0</version>
550550
<extensions>true</extensions>
551551
<configuration>
552-
<serverId>ossrh</serverId>
553-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
554-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
552+
<publishingServerId>central</publishingServerId>
553+
<tokenAuth>true</tokenAuth>
554+
<autoPublish>true</autoPublish>
555+
<waitUntil>published</waitUntil>
555556
</configuration>
556557
</plugin>
557558
</plugins>

0 commit comments

Comments
 (0)