Skip to content

Commit 082263a

Browse files
committed
Fix Maven Central publishing pipeline
- Switch JFrog CLI from stale secrets.ARTIFACTORY_URL to secrets.JF_URL - Migrate Maven Central publishing from deprecated oss.sonatype.org (nexus-staging-maven-plugin) to Sonatype Central Portal (central-publishing-maven-plugin) - Update settings.xml server-id from ossrh to central, using new CENTRAL_USERNAME/CENTRAL_PASSWORD secrets - Fix GPG passphrase timing by exposing OSSRH_GPG_PASSPHRASE at job level so setup-java can pre-cache it into the GPG agent
1 parent 40d65cf commit 082263a

2 files changed

Lines changed: 32 additions & 29 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
name: Release
2-
32
on:
43
workflow_dispatch:
54
release:
65
types: published
6+
77
jobs:
88
release:
99
runs-on: ubuntu-latest
10+
env:
11+
OSSRH_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }}
1012
steps:
1113
- uses: actions/checkout@v4
1214

13-
# Configure Java 8 and generate a settings.xml file containing the OSSRH credentials
14-
- name: Set up Maven Central Repository
15+
- name: Set up Java 8
1516
uses: actions/setup-java@v3
1617
with:
1718
distribution: "temurin"
1819
java-version: "8"
19-
server-id: ossrh
20-
server-username: OSSRH_USERNAME
21-
server-password: OSSRH_PASSWORD
20+
server-id: central
21+
server-username: CENTRAL_USERNAME
22+
server-password: CENTRAL_PASSWORD
2223
gpg-private-key: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
2324
gpg-passphrase: OSSRH_GPG_PASSPHRASE
2425

2526
- name: Install jfrog cli
2627
uses: jfrog/setup-jfrog-cli@v4
2728
env:
28-
JF_URL: ${{ secrets.ARTIFACTORY_URL }}
29-
JF_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
29+
JF_URL: ${{ secrets.JF_URL }}
30+
JF_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
3031

3132
- name: Scan with jfrog audit
3233
run: jfrog audit
3334

34-
# Run mvn install
3535
- name: Install
3636
run: mvn install -B
3737

38-
# Deploy to Maven Central
3938
- name: Deploy to Maven Central
4039
run: mvn -B deploy -Pupload-to-central
4140
env:
42-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
43-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
41+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
42+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
4443
OSSRH_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }}

pom.xml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
34
<modelVersion>4.0.0</modelVersion>
5+
46
<groupId>org.jfrog.buildinfo</groupId>
57
<artifactId>artifactory-maven-plugin</artifactId>
68
<packaging>maven-plugin</packaging>
@@ -22,13 +24,10 @@
2224

2325
<distributionManagement>
2426
<snapshotRepository>
25-
<id>ossrh</id>
26-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
27+
<!-- Points to new Central Portal snapshot repo (not legacy oss.sonatype.org) -->
28+
<id>central</id>
29+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
2730
</snapshotRepository>
28-
<repository>
29-
<id>ossrh</id>
30-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
31-
</repository>
3231
</distributionManagement>
3332

3433
<prerequisites>
@@ -225,7 +224,6 @@
225224
<version>1.18.36</version>
226225
<scope>provided</scope>
227226
</dependency>
228-
229227
<dependency>
230228
<groupId>com.google.guava</groupId>
231229
<artifactId>guava</artifactId>
@@ -378,7 +376,6 @@
378376
</execution>
379377
</executions>
380378
</plugin>
381-
382379
<!--Unit tests-->
383380
<plugin>
384381
<groupId>org.apache.maven.plugins</groupId>
@@ -390,7 +387,6 @@
390387
</excludes>
391388
</configuration>
392389
</plugin>
393-
394390
<!--Integration tests-->
395391
<plugin>
396392
<groupId>org.apache.maven.plugins</groupId>
@@ -422,8 +418,8 @@
422418
<id>release</id>
423419
<activation>
424420
<!--
425-
In order to allow to install the plugin before using it in deployment,
426-
we activate the 'release' profile only if Artifactory URL is specified.
421+
In order to allow to install the plugin before using it in deployment,
422+
we activate the 'release' profile only if Artifactory URL is specified.
427423
-->
428424
<property>
429425
<name>ARTIFACTORY_URL</name>
@@ -457,11 +453,13 @@
457453
</plugins>
458454
</build>
459455
</profile>
456+
460457
<profile>
461458
<!-- Use this profile to sign and upload the JAR to Maven Central -->
462459
<id>upload-to-central</id>
463460
<build>
464461
<plugins>
462+
<!-- GPG signing — required by Maven Central -->
465463
<plugin>
466464
<groupId>org.apache.maven.plugins</groupId>
467465
<artifactId>maven-gpg-plugin</artifactId>
@@ -482,19 +480,25 @@
482480
</execution>
483481
</executions>
484482
</plugin>
483+
484+
<!-- Central Portal publisher — replaces legacy nexus-staging-maven-plugin -->
485485
<plugin>
486-
<groupId>org.sonatype.plugins</groupId>
487-
<artifactId>nexus-staging-maven-plugin</artifactId>
488-
<version>1.6.8</version>
486+
<groupId>org.sonatype.central</groupId>
487+
<artifactId>central-publishing-maven-plugin</artifactId>
488+
<version>0.7.0</version>
489489
<extensions>true</extensions>
490490
<configuration>
491-
<serverId>ossrh</serverId>
492-
<nexusUrl>https://oss.sonatype.org</nexusUrl>
493-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
491+
<!-- Must match the server id in settings.xml written by the workflow -->
492+
<publishingServerId>central</publishingServerId>
493+
<!-- Automatically promote from staging to published -->
494+
<autoPublish>true</autoPublish>
495+
<!-- Block the build until Central confirms the artifact is live -->
496+
<waitUntil>published</waitUntil>
494497
</configuration>
495498
</plugin>
496499
</plugins>
497500
</build>
498501
</profile>
499502
</profiles>
503+
500504
</project>

0 commit comments

Comments
 (0)