Skip to content

Commit 3a60c4d

Browse files
committed
publishing fixes
1 parent 60d6fa0 commit 3a60c4d

3 files changed

Lines changed: 20 additions & 32 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ jobs:
3030
echo "Version from tag: $VERSION"
3131
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
3232
33-
- name: Configure Maven settings
33+
- name: Configure Maven settings (Sonatype Central)
3434
run: |
3535
cat > $GITHUB_WORKSPACE/maven-settings.xml <<'SETTINGS'
3636
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3737
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
3838
<servers>
3939
<server>
40-
<id>ossrh</id>
41-
<username>${env.OSSRH_USERNAME}</username>
42-
<password>${env.OSSRH_PASSWORD}</password>
40+
<id>central</id>
41+
<username>${env.CENTRAL_USERNAME}</username>
42+
<password>${env.CENTRAL_PASSWORD}</password>
4343
</server>
4444
</servers>
4545
</settings>
@@ -60,12 +60,11 @@ jobs:
6060
run: |
6161
mvn -q -B versions:set -DnewVersion=${{ steps.vars.outputs.version }} -DgenerateBackupPoms=false
6262
63-
- name: Build and deploy to Maven Central
63+
- name: Build and publish to Maven Central (Sonatype Central)
6464
env:
65-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
66-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
65+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
66+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
6767
GPG_TTY: $(tty)
6868
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
6969
run: |
70-
mvn -B -s $GITHUB_WORKSPACE/maven-settings.xml -P release -DskipTests deploy -Dgpg.passphrase=$GPG_PASSPHRASE
71-
70+
mvn -B -s $GITHUB_WORKSPACE/maven-settings.xml -P release -DskipTests -Dgpg.passphrase=$GPG_PASSPHRASE clean package central:publish

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,15 @@ nix-shell --run "mvn -q -DskipTests compile && java -cp target/classes sh.scarf.
128128
Publishing
129129
----------
130130

131-
Publishing uses Git tags and GitHub Actions to deploy to Maven Central.
131+
Publishing uses Git tags and GitHub Actions to deploy to Maven Central via Sonatype Central (modern flow).
132132

133133
Setup (one-time)
134-
- Create an account on Sonatype OSSRH and request the `sh.scarf` groupId if not already owned.
134+
- Create an account on Sonatype Central and ensure ownership of the `sh.scarf` groupId.
135+
- Create a Publishing Token in Sonatype Central (username is typically `token`, password is the token value).
135136
- Generate a GPG key (publishing requires signed artifacts).
136137
- Add the following GitHub repository secrets:
137-
- `OSSRH_USERNAME`: Your OSSRH username (or token user: e.g., `token` if using the new tokens)
138-
- `OSSRH_PASSWORD`: Your OSSRH password (or token value)
138+
- `CENTRAL_USERNAME`: Your Central publishing username (often `token`)
139+
- `CENTRAL_PASSWORD`: Your Central publishing token value
139140
- `GPG_PRIVATE_KEY`: Base64-encoded ASCII-armored private key
140141
- `GPG_PASSPHRASE`: Passphrase for the key
141142

@@ -149,8 +150,7 @@ git push origin v0.1.0
149150

150151
The `Release` workflow will:
151152
- Set the Maven project version to `0.1.0`
152-
- Build, sign, and deploy to OSSRH
153-
- Auto-close and release the staging repository
153+
- Build, sign, and publish to Maven Central via Sonatype Central tokens
154154

155155

156156
License

pom.xml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,19 @@
145145
</executions>
146146
</plugin>
147147

148-
<!-- Deploy to OSSRH (Nexus Staging) -->
148+
<!-- Publish to Sonatype Central using tokens -->
149149
<plugin>
150-
<groupId>org.sonatype.plugins</groupId>
151-
<artifactId>nexus-staging-maven-plugin</artifactId>
152-
<version>1.6.13</version>
150+
<groupId>org.sonatype.central</groupId>
151+
<artifactId>central-publishing-maven-plugin</artifactId>
152+
<version>0.4.0</version>
153153
<extensions>true</extensions>
154154
<configuration>
155-
<serverId>ossrh</serverId>
156-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
157-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
155+
<!-- Server defined in ~/.m2/settings.xml or provided settings.xml -->
156+
<publishingServerId>central</publishingServerId>
158157
</configuration>
159158
</plugin>
160159
</plugins>
161160
</build>
162-
<distributionManagement>
163-
<snapshotRepository>
164-
<id>ossrh</id>
165-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
166-
</snapshotRepository>
167-
<repository>
168-
<id>ossrh</id>
169-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
170-
</repository>
171-
</distributionManagement>
172161
</profile>
173162
</profiles>
174163
</project>

0 commit comments

Comments
 (0)