Skip to content

Commit 2364eb5

Browse files
committed
Setup a new release process to be used after the deprecation of OSSRH
CC: https://central.sonatype.org/news/20250326_ossrh_sunset/
1 parent 6381b7b commit 2364eb5

File tree

5 files changed

+47
-76
lines changed

5 files changed

+47
-76
lines changed

.github/workflows/ossrh-publish.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags: ["v*"] # Trigger on version tag pushes (adjust as needed)
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v4
16+
with:
17+
distribution: 'temurin'
18+
java-version: '17'
19+
20+
- name: Publish to Sonatype Central
21+
env:
22+
# Pass Sonatype portal token credentials to Gradle
23+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
24+
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
25+
MAVEN_CENTRAL_SIGNING_KEY: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY }}
26+
MAVEN_CENTRAL_SIGNING_PASSWORD: ${{ secrets.MAVEN_CENTRAL_SIGNING_PASSWORD }}
27+
run: ./gradlew clean publishToSonatype closeAndReleaseSonatypeStagingRepository

CONTRIBUTING.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,22 @@ gpg --gen-key --batch genkey
199199
gpg --keyserver hkp://keyserver.ubuntu.com --send-keys <last-8-digits-of-your-key-hash>
200200
```
201201

202-
5. Export the gpg key in a secring.gpg file
202+
5. Export the gpg key in a signing-key.asc armored file
203203

204204
```bash
205-
gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg
206-
```
207-
208-
6. Encode the secring in base64 and store it (Used by the ossrh-publish workflow)
209-
210-
```bash
211-
base64 ~/.gnupg/secring.gpg > secring.gpg.b64
205+
gpg --armor --export-secret-keys $KEY_ID > signing-key.asc
212206
```
213207

214208
#### Sign your files and upload to Maven Repository manually <!-- omit in TOC -->
215209

216210
1. Set the environment variables listed below with the required credentials:
217211

218212
```bash
219-
export OSSRH_USERNAME=<maven-username>
220-
export OSSRH_PASSWORD=<maven-password>
213+
export MAVEN_CENTRAL_USERNAME=<maven-username>
214+
export MAVEN_CENTRAL_PASSWORD=<maven-password>
221215

222216
export SIGNINT_KEY_ID=<id-associated-to-the-gpg-key>
223217
export SIGNING_PASSWORD=<passphrase-associated-to-the-gpg-key>
224-
export SIGNING_SECRET_KEY_RING_FILE=<path-to-gpg-key-encoded-in-base64>
225218
```
226219

227220
2. Decode the gpg key
@@ -235,13 +228,13 @@ base64 -d $SIGNING_SECRET_KEY_RING_FILE > secring.gpg
235228
```bash
236229
# May need sudo privilege and JDK8
237230
./gradlew build
238-
./gradlew publish -Psigning.keyId=$SIGNING_KEY_ID -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=$(echo secring.gpg)
231+
TODO
239232
```
240233

241-
4. Login to [Sonatype Nexus](https://oss.sonatype.org).
242-
5. Navigate to `Staging repositories`.
243-
6. Close your repository by clicking on the `Close` button. Checks will be made by nexus. It might take time. If any error occurs, it will be visible in the `Activity` tab.
244-
7. Once the check have succeeded, you should be able to click on the `Release` button. The release will be now processed and might take a long time to appear in [Maven Central](https://search.maven.org/artifact/com.meilisearch.sdk/meilisearch-java).
234+
4. Login to [Sonatype Nexus](https://central.sonatype.com/).
235+
5. Navigate to `Deployments`.
236+
6. Checks will be made by Sonatype. It might take time. If any error occurs, it will be visible in the `Deployments` tab (last one).
237+
7. Once the check have succeeded, the release will be now processed and it will appear in [Maven Central](https://central.sonatype.com/artifact/com.meilisearch.sdk/meilisearch-java/versions).
245238

246239
<hr>
247240

build.gradle

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
id 'maven-publish'
1313
id 'signing'
1414
id 'jacoco'
15-
id 'io.github.gradle-nexus.publish-plugin' version "2.0.0"
15+
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
1616
id "com.diffplug.spotless" version "6.13.0"
1717
}
1818

@@ -159,33 +159,25 @@ publishing {
159159
}
160160
}
161161
}
162-
repositories {
163-
maven {
164-
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
165-
credentials {
166-
username System.getenv('OSSRH_USERNAME')
167-
password System.getenv('OSSRH_PASSWORD')
168-
}
169-
}
170-
}
171162
}
172163

173164
nexusPublishing {
174-
packageGroup = "com.meilisearch"
175-
176165
repositories {
177166
sonatype {
178-
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
179-
180-
username = System.getenv('OSSRH_USERNAME')
181-
password = System.getenv('OSSRH_PASSWORD')
182-
stagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID')
167+
// Point to new Central Portal staging API (replaces oss.sonatype.org)
168+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
169+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
170+
// Credentials: use Central Portal token (username/password)
171+
username.set(System.getenv("MAVEN_CENTRAL_USERNAME")) // portal token user
172+
password.set(System.getenv("MAVEN_CENTRAL_PASSWORD")) // portal token password
173+
// packageGroup or stagingProfileId not needed if using nexus-publish-plugin
183174
}
184175
}
185176
}
186177

187178
signing {
188-
sign publishing.publications.mavenJava
179+
useInMemoryPgpKeys(System.getenv("MAVEN_CENTRAL_SIGNING_KEY"), System.getenv("MAVEN_CENTRAL_SIGNING_PASSWORD"))
180+
sign(publishing.publications["mavenJava"])
189181
}
190182

191183
javadoc {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)