diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a6b1ba..3d73a37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,12 +34,16 @@ jobs: echo "version=${VERSION}" >> $GITHUB_OUTPUT - - name: Upload the package to GitHub Package + - name: Upload the package to Maven Central Repository run: | + echo "${{ secrets.SIGNING_SECRET_KEY_RING }}" | base64 -d > ~/.gradle/secring.gpg ./gradlew publish \ -PprojVersion="${{ steps.version.outputs.version }}" \ - -PgprUsername="${{ github.repository_owner }}" \ - -PgprPassword="${{ secrets.CR_PAT }}" + -Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}" \ + -Psigning.password="${{ secrets.SIGNING_PASSWORD }}" \ + -Psigning.secretKeyRingFile="$(echo ~/.gradle/secring.gpg)" \ + -PossrhUsername="${{ secrets.OSSRH_USERNAMAE }}" \ + -PossrhPassword="${{ secrets.OSSRH_PASSWORD }}" - name: Build the shadow Jar run: ./gradlew shadowJar diff --git a/lib/archive.gradle b/lib/archive.gradle index 70722bc..6d7b268 100644 --- a/lib/archive.gradle +++ b/lib/archive.gradle @@ -1,4 +1,5 @@ apply plugin: 'maven-publish' +apply plugin: 'signing' publishing { publications { @@ -37,11 +38,17 @@ publishing { } repositories { maven { - url = uri("https://maven.pkg.github.com/scalar-labs/scalar-admin-k8s") + def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl credentials { - username = project.findProperty("gprUsername") ?: System.getenv("GPR_USERNAME") - password = project.findProperty("gprPassword") ?: System.getenv("GPR_PASSWORD") + username = "${ossrhUsername}" + password = "${ossrhPassword}" } } } } + +signing { + sign publishing.publications.mavenJava +}