Skip to content

Commit

Permalink
using jreleaser to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
yangbo committed Sep 3, 2024
1 parent 2fb8b08 commit d032c02
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
java-version: '17'
- name: prepare
run: |
chmod a+x ./gradlew
echo "${{ secrets.SIGNING_SECRET_KEY_RING_KEY }}" | base64 -d > ~/secring.gpg
run: chmod a+x ./gradlew
- name: build
run: ./gradlew :build
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: publish
run: ./gradlew :publish -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/secring.gpg)
run: ./gradlew :publish
- name: release
run: ./gradlew :jreleaserRelease
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }}
JRELEASER_GITHUB_TOKEN: 'none'
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
31 changes: 19 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import java.nio.charset.StandardCharsets
import java.util.stream.Collectors

plugins {
id 'java-library'
id 'io.freefair.lombok' version '6.6.1'
id 'io.freefair.lombok' version '8.10'
id 'maven-publish'
id 'signing'
id 'org.jreleaser' version '1.14.0'
}

group 'io.github.ya-b'
Expand Down Expand Up @@ -87,17 +85,26 @@ publishing {
}
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 System.getenv("SONATYPE_USERNAME")
password System.getenv("SONATYPE_PASSWORD")
}
url = layout.buildDirectory.dir('staging-deploy')
}
}
}

jreleaser {
signing {
sign publishing.publications.mavenJava
active = 'ALWAYS'
armored = true
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit d032c02

Please sign in to comment.