From 4f2045361d2722a0acc7bd0d3f5a77f7d82ee17f Mon Sep 17 00:00:00 2001 From: Andy Coates <8012398+big-andy-coates@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:15:11 +0000 Subject: [PATCH] OSSRH publishing (#32) --- .github/workflows/build.yml | 4 +++- build.gradle.kts | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58a81d02..fccb1695 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,10 +44,12 @@ jobs: env: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} + ORG_GRADLE_PROJECT_SONA_USERNAME: ${{ secrets.SONA_USERNAME }} + ORG_GRADLE_PROJECT_SONA_PASSWORD: ${{ secrets.SONA_PASSWORD }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ./gradlew cV - ./gradlew publish + ./gradlew publish closeSonatypeStagingRepository # todo: switch to closeAndReleaseStagingRepository to auto release. create-gh-release: if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-alpha') diff --git a/build.gradle.kts b/build.gradle.kts index 73e4217e..ad0fafdc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ plugins { id("com.github.spotbugs") version "4.7.2" id("com.diffplug.spotless") version "6.11.0" id("pl.allegro.tech.build.axion-release") version "1.14.3" + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" } project.version = scmVersion.version @@ -163,7 +164,6 @@ subprojects { } publishing { - repositories { maven { name = "GitHubPackages" @@ -240,4 +240,21 @@ subprojects { } } +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + + if (project.hasProperty("SONA_USERNAME")) { + username.set(project.property("SONA_USERNAME").toString()) + } + + if (project.hasProperty("SONA_PASSWORD")) { + password.set(project.property("SONA_PASSWORD").toString()) + } + } + } +} + defaultTasks("format", "static", "check") \ No newline at end of file