Skip to content

Commit c8f7c38

Browse files
Jose AngelJose Angel
authored andcommitted
fix(ci): migrate Java publishing to Central Portal
- Replace OSSRH with Central Publishing Portal (OSSRH EOL June 2025) - Update pom.xml to use central-publishing-maven-plugin - Configure tokenAuth for Central Portal authentication - Simplify workflow using setup-java credential management
1 parent 8a335ac commit c8f7c38

3 files changed

Lines changed: 21 additions & 31 deletions

File tree

.github/settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
http://maven.apache.org/xsd/settings-1.0.0.xsd">
55
<servers>
66
<server>
7-
<id>ossrh</id>
7+
<id>central</id>
88
<username>${env.SONATYPE_USERNAME}</username>
99
<password>${env.SONATYPE_PASSWORD}</password>
1010
</server>

.github/workflows/java.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ jobs:
1818
with:
1919
distribution: 'temurin'
2020
java-version: '21'
21+
server-id: central
22+
server-username: MAVEN_USERNAME
23+
server-password: MAVEN_PASSWORD
24+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
25+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2126

2227
- name: Install ANTLR4
2328
run: make dev
2429

25-
- name: Import GPG key
26-
uses: crazy-max/ghaction-import-gpg@v6
27-
with:
28-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
29-
passphrase: ${{ secrets.GPG_PASSPHRASE }}
30-
3130
- name: Set SNAPSHOT version (develop branch)
3231
if: github.ref == 'refs/heads/develop'
3332
run: |
@@ -52,18 +51,9 @@ jobs:
5251
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
5352
restore-keys: ${{ runner.os }}-m2
5453

55-
- name: Deploy SNAPSHOT to OSSRH (develop branch)
56-
if: github.ref == 'refs/heads/develop'
57-
run: cd java && mvn clean deploy --settings ../.github/settings.xml
58-
env:
59-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
60-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
61-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
62-
63-
- name: Deploy Release to Maven Central (tag)
64-
if: startsWith(github.ref, 'refs/tags/v')
65-
run: cd java && mvn clean deploy --settings ../.github/settings.xml
54+
- name: Deploy to Central Portal
55+
run: cd java && mvn clean deploy -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
6656
env:
67-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
68-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
69-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
57+
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
58+
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
59+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

java/pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@
7272

7373
<distributionManagement>
7474
<snapshotRepository>
75-
<id>ossrh</id>
76-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
75+
<id>central</id>
76+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
7777
</snapshotRepository>
7878
<repository>
79-
<id>ossrh</id>
80-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
79+
<id>central</id>
80+
<url>https://central.sonatype.com/</url>
8181
</repository>
8282
</distributionManagement>
8383

@@ -156,14 +156,14 @@
156156
</plugin>
157157

158158
<plugin>
159-
<groupId>org.sonatype.plugins</groupId>
160-
<artifactId>nexus-staging-maven-plugin</artifactId>
161-
<version>1.7.0</version>
159+
<groupId>org.sonatype.central</groupId>
160+
<artifactId>central-publishing-maven-plugin</artifactId>
161+
<version>0.6.0</version>
162162
<extensions>true</extensions>
163163
<configuration>
164-
<serverId>ossrh</serverId>
165-
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
166-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
164+
<publishingServerId>central</publishingServerId>
165+
<tokenAuth>true</tokenAuth>
166+
<autoPublish>true</autoPublish>
167167
</configuration>
168168
</plugin>
169169

0 commit comments

Comments
 (0)