diff --git a/.github/workflows/ossrh-publish.yml b/.github/workflows/ossrh-publish.yml deleted file mode 100644 index c52603de..00000000 --- a/.github/workflows/ossrh-publish.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: OSSRH - -on: - push: - tags: - - v* - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Java - uses: actions/setup-java@v4 - with: - java-version: 8 - distribution: 'zulu' - cache: gradle - - name: Check release validity - run: bash .github/scripts/check-release.sh - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build -x test - - name: Archive test report - uses: actions/upload-artifact@v4 - if: failure() - with: - name: Test report - path: build/reports/tests/test - if-no-files-found: ignore - - name: Decode secring.gpg - run: | - echo "${{secrets.SIGNING_SECRET_KEY_RING_FILE}}" > ~/.gradle/secring.gpg.b64 - base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg - - name: Publish, close and release Nexus Repository - run: ./gradlew publishToSonatype closeAndReleaseStagingRepositories -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) - env: - OSSRH_USERNAME: ${{secrets.OSSRH_USERNAME}} - OSSRH_PASSWORD: ${{secrets.OSSRH_PASSWORD}} - SONATYPE_STAGING_PROFILE_ID: ${{secrets.SONATYPE_STAGING_PROFILE_ID}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..c266c18f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,27 @@ +name: Publish to Maven Central + +on: + push: + tags: ["v*"] # Trigger on version tag pushes (adjust as needed) + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - name: Publish to Sonatype Central + env: + # Pass Sonatype portal token credentials to Gradle + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + MAVEN_CENTRAL_SIGNING_KEY: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY }} + MAVEN_CENTRAL_SIGNING_PASSWORD: ${{ secrets.MAVEN_CENTRAL_SIGNING_PASSWORD }} + run: ./gradlew clean publishToSonatype closeAndReleaseSonatypeStagingRepository diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5afd169..73e27c48 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -199,16 +199,10 @@ gpg --gen-key --batch genkey gpg --keyserver hkp://keyserver.ubuntu.com --send-keys ``` -5. Export the gpg key in a secring.gpg file +5. Export the gpg key in a signing-key.asc armored file ```bash -gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg -``` - -6. Encode the secring in base64 and store it (Used by the ossrh-publish workflow) - -```bash -base64 ~/.gnupg/secring.gpg > secring.gpg.b64 +gpg --armor --export-secret-keys $KEY_ID > signing-key.asc ``` #### Sign your files and upload to Maven Repository manually @@ -216,12 +210,11 @@ base64 ~/.gnupg/secring.gpg > secring.gpg.b64 1. Set the environment variables listed below with the required credentials: ```bash -export OSSRH_USERNAME= -export OSSRH_PASSWORD= +export MAVEN_CENTRAL_USERNAME= +export MAVEN_CENTRAL_PASSWORD= export SIGNINT_KEY_ID= export SIGNING_PASSWORD= -export SIGNING_SECRET_KEY_RING_FILE= ``` 2. Decode the gpg key @@ -235,13 +228,13 @@ base64 -d $SIGNING_SECRET_KEY_RING_FILE > secring.gpg ```bash # May need sudo privilege and JDK8 ./gradlew build -./gradlew publish -Psigning.keyId=$SIGNING_KEY_ID -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=$(echo secring.gpg) +TODO ``` -4. Login to [Sonatype Nexus](https://oss.sonatype.org). -5. Navigate to `Staging repositories`. -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. -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). +4. Login to [Sonatype Nexus](https://central.sonatype.com/). +5. Navigate to `Deployments`. +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). +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).
diff --git a/build.gradle b/build.gradle index e6a15a25..f20cb977 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ plugins { id 'maven-publish' id 'signing' id 'jacoco' - id 'io.github.gradle-nexus.publish-plugin' version "2.0.0" + id "io.github.gradle-nexus.publish-plugin" version "2.0.0" id "com.diffplug.spotless" version "6.13.0" } @@ -159,33 +159,25 @@ publishing { } } } - repositories { - maven { - url "https://oss.sonatype.org/service/local/staging/deploy/maven2" - credentials { - username System.getenv('OSSRH_USERNAME') - password System.getenv('OSSRH_PASSWORD') - } - } - } } nexusPublishing { - packageGroup = "com.meilisearch" - repositories { sonatype { - nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) - - username = System.getenv('OSSRH_USERNAME') - password = System.getenv('OSSRH_PASSWORD') - stagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID') + // Point to new Central Portal staging API (replaces oss.sonatype.org) + nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) + snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) + // Credentials: use Central Portal token (username/password) + username.set(System.getenv("MAVEN_CENTRAL_USERNAME")) // portal token user + password.set(System.getenv("MAVEN_CENTRAL_PASSWORD")) // portal token password + // packageGroup or stagingProfileId not needed if using nexus-publish-plugin } } } signing { - sign publishing.publications.mavenJava + useInMemoryPgpKeys(System.getenv("MAVEN_CENTRAL_SIGNING_KEY"), System.getenv("MAVEN_CENTRAL_SIGNING_PASSWORD")) + sign(publishing.publications["mavenJava"]) } javadoc { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c85a1f7..942039f2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists