From 8d86b6d3f4ed5453d027a5c3cec3577eeab7b3ef Mon Sep 17 00:00:00 2001 From: "Omar \"Goatfryed\" Sood" Date: Tue, 10 Sep 2024 22:47:16 +0200 Subject: [PATCH] ci: setup github actions to verify and release --- .github/workflows/publish.yml | 22 ++++++++++++++++++++++ .github/workflows/verify.yml | 20 ++++++++++++++++++++ build.gradle | 21 +++++++++++++++++---- gradle.properties | 5 +++++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/verify.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..df8a98b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,22 @@ +name: Publish package to the Maven Central Repository +on: + release: + types: [published] +jobs: + publish-release: + runs-on: ubuntu-latest + environment: release + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + - uses: gradle/actions/setup-gradle@v4 + - name: Publish + run: ./gradlew publish + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingPrivateKey: ${{ secrets.GPG_SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGING_PASSPHRASE }} \ No newline at end of file diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..53ad4cc --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,20 @@ +name: Publish package to the Maven Central Repository +on: + pull_request: + branches: + - main + push: + branches: + - main +jobs: + publish-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + - uses: gradle/actions/setup-gradle@v4 + - name: Verify + run: ./gradlew check diff --git a/build.gradle b/build.gradle index f841a4b..007b898 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { // Apply the java-library plugin for API and implementation separation. id 'java-library' id 'maven-publish' + id 'signing' } group = "io.github.goatfryed" @@ -91,7 +92,7 @@ tasks.named('javadoc', Javadoc) { publishing { publications { - mavenJava(MavenPublication) { + lib(MavenPublication) { from components.java pom { @@ -113,6 +114,12 @@ publishing { email = 'goatfryed@gmail.com' } } + + scm { + connection = 'scm:git:git://github.com/goatfryed/assert-baseline.git' + developerConnection = 'scm:git:ssh://github.com/goatfryed/assert-baseline.git' + url = 'github.com/goatfryed/assert-baseline' + } } } } @@ -120,9 +127,15 @@ publishing { repositories { maven { name = 'MavenCentral' - url = version.endsWith('SNAPSHOT') ? - uri('https://s01.oss.sonatype.org/content/repositories/snapshots/') : - uri('https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/') + url = uri('https://central.sonatype.com/api/v1/publisher') + credentials(org.gradle.api.credentials.PasswordCredentials) } } +} + +signing { + def signingKey = findProject("signing.privateKey") + def signingPassword = findProject("signing.password") + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 18f452c..0e6f7d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,8 @@ org.gradle.parallel=true org.gradle.caching=true +signingPrivateKey= +signingPassword= +mavenCentralUsername= +mavenCentralPassword= +