Skip to content

Commit

Permalink
Use JReleaser (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludorival authored Nov 30, 2024
1 parent c98eb53 commit cec039f
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 97 deletions.
Binary file removed .github/secret/secret-keys.gpg
Binary file not shown.
27 changes: 0 additions & 27 deletions .github/workflows/build.yaml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build and Deploy

on:
push:
branches: [ main ]
tags:
- '*'


permissions:
checks: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
checks: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6
- name: Build with Gradle
run: ./gradlew build

- name: Deploy with JReleaser
if: startsWith(github.ref, 'refs/tags/')
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
run: ./gradlew publish jreleaserDeploy
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: JUnit Tests
path: "build/test-results/test/*.xml"
reporter: java-junit
fail-on-error: true

create-release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
48 changes: 0 additions & 48 deletions .github/workflows/publish.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/pullRequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pull Request Build

on:
pull_request:
branches: [ main ]


permissions:
checks: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
checks: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6
- name: Build with Gradle
run: ./gradlew build

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: JUnit Tests
path: "build/test-results/test/*.xml"
reporter: java-junit
fail-on-error: true
46 changes: 24 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ plugins {
id 'org.jetbrains.kotlin.jvm' version '1.7.20'
id 'maven-publish'
id 'org.jetbrains.kotlinx.kover' version '0.4.4'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version "1.1.0"
id 'com.palantir.git-version' version '0.15.0'
id 'org.jreleaser' version '1.15.0'
}

group 'io.github.ludorival'
Expand Down Expand Up @@ -62,27 +62,7 @@ publishing {
}
repositories {
maven {
name = "OSSRH"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = findProperty("maven.username") ?: System.getenv("OSSRH_USERNAME")
password = findProperty("maven.password") ?: System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD")
}

}
}
}

signing {
sign publishing.publications.mavenJava
}
nexusPublishing {
repositories {
sonatype {
username = findProperty("maven.username") ?: System.getenv("OSSRH_USERNAME")
password = findProperty("maven.password") ?: System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD")
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
url = uri("$buildDir/staging-deploy")
}
}
}
Expand Down Expand Up @@ -114,3 +94,25 @@ dependencies {
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
}

jreleaser {
signing {
active = 'ALWAYS'
armored = true
}

deploy {
maven {
mavenCentral {
sonatype {
applyMavenCentralRules = true
password = findProperty('maven.password') ?: System.getenv('MAVEN_CENTRAL_PASSWORD')
username = findProperty('maven.username') ?: System.getenv('MAVEN_CENTRAL_USERNAME')
active = 'ALWAYS'
url = 'https://s01.oss.sonatype.org/service/local/'
stagingRepository('build/staging-deploy')
}
}
}
}
}

0 comments on commit cec039f

Please sign in to comment.