diff --git a/.github/workflows/publish-workflow.yaml b/.github/workflows/publish-workflow.yaml new file mode 100644 index 0000000..2375383 --- /dev/null +++ b/.github/workflows/publish-workflow.yaml @@ -0,0 +1,35 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish package to the Staging Maven Central Repository +on: + release: + types: [created] +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + - name: Publish package + run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 38bff97..a20b324 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ plugins { id("net.ltgt.errorprone") version "3.0.1" apply false id "org.sonarqube" version "4.2.1.3168" id "jacoco" + id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-2" } apply(plugin: "java-library"); @@ -184,21 +185,24 @@ publishing { } } } +} + +nexusPublishing { repositories { - maven { - def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - - credentials { - username = ossrhUsername - password = ossrhPassword - } + sonatype { //only for users registered in Sonatype after 24 Feb 2021 + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + username = System.getenv("OSSRH_USERNAME") + password = System.getenv("OSSRH_PASSWORD") } } } signing { required { gradle.taskGraph.hasTask("publish") } + def signingKeyId = System.getenv("SIGNING_KEY_ID") + def signingKey = System.getenv("SIGNING_KEY") + def signingPassword = System.getenv("SIGNING_PASSWORD") + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) sign publishing.publications.mavenJava } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7a84135..a80dc36 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1 @@ -version=2.0.2 -signing.keyId=YourKeyId -signing.password=YourPublicKeyPassword -signing.secretKeyRingFile=PathToYourKeyRingFile - -ossrhUsername=your-jira-id -ossrhPassword=your-jira-password +version=2.0.3