Skip to content

Commit

Permalink
Merge pull request #71 from gravity9-tech/feature/automatic_central_p…
Browse files Browse the repository at this point in the history
…ublication

Feature/automatic central publication
  • Loading branch information
BartekGravity authored May 9, 2024
2 parents 03ab4ee + 51d5221 commit 8739ea9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/publish-workflow.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
22 changes: 13 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
}
8 changes: 1 addition & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8739ea9

Please sign in to comment.