From bd74f6e137c76daef43c337890a12b68ef7a78f7 Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 8 Jul 2025 14:42:33 -0700 Subject: [PATCH] Update build and publish workflow to use new sonatype platform --- .github/workflows/publish_release.yml | 21 +++++++++++++++++++++ build.gradle | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 532ddf6..f110df4 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -23,3 +23,24 @@ jobs: ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} run: ./gradlew build publish -Prelease=true + + - name: Upload staged artifacts to Central Sonatype + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: | + SONATYPE_TOKEN=$(printf "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64) + PUBLISH_NAMESPACE="com.newrelic.opentracing" + echo "Uploading artifacts from OSSRH-Staging to Central Sonatype..." + RESPONSE=$(curl -s -w "%{http_code}" -o response_body.txt -X POST \ + -H "Authorization: Bearer $SONATYPE_TOKEN" \ + "https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$PUBLISH_NAMESPACE?publishing_type=user_managed") + if [ "$RESPONSE" -ne 200 ]; then + echo "Failed to upload artifacts to Central Sonatype. Response code: $RESPONSE. Response body: " + cat response_body.txt + echo "Visit https://central.sonatype.com/publishing/deployments for more information." + exit 1 + else + echo "Artifacts were uploaded successfully to Central Sonatype." + echo "Visit https://central.sonatype.com/publishing/deployments to view your artifacts." + fi \ No newline at end of file diff --git a/build.gradle b/build.gradle index ea5fab0..288b765 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ java { repositories { mavenCentral() maven { - url 'https://oss.sonatype.org/content/repositories/snapshots' + url 'https://central.sonatype.com/repository/maven-snapshots/' } } @@ -70,8 +70,8 @@ jar { publishing { repositories { maven { - def releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - def snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/") + def releasesRepoUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/") + def snapshotsRepoUrl = uri("https://central.sonatype.com/repository/maven-snapshots/") if (version.toString().endsWith("SNAPSHOT")) { url = snapshotsRepoUrl } else {