Skip to content

Commit 7e47bcf

Browse files
feeblefakiejnmt
andauthored
Backport to branch(3.10) : Use JReleaser to release artifacts in Maven Central (#197)
Co-authored-by: Jun Nemoto <[email protected]>
1 parent 6b6df26 commit 7e47bcf

File tree

8 files changed

+91
-69
lines changed

8 files changed

+91
-69
lines changed

.github/workflows/release-snapshot.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,28 @@ jobs:
3030
VERSION=$(./gradlew :ledger:properties -q | grep "version:" | awk '{print $2}')
3131
echo "version=${VERSION}" >> $GITHUB_OUTPUT
3232
33+
- name: Prepare artifacts in staging-deploy directories
34+
if: contains(steps.version.outputs.version, '-SNAPSHOT')
35+
run: ./gradlew publish
36+
3337
- name: Upload the SNAPSHOT versions of scalardl-ledger, scalardl-java-client-sdk, scalardl-common, and scalardl-rpc to Maven Central Repository
3438
if: contains(steps.version.outputs.version, '-SNAPSHOT')
35-
run: |
36-
echo "${{secrets.SIGNING_SECRET_KEY_RING}}" | base64 -d > /tmp/secring.gpg
37-
./gradlew publish \
38-
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}" \
39-
-P'signing.password'="${{ secrets.SIGNING_PASSWORD }}" \
40-
-Psigning.secretKeyRingFile="$(echo /tmp/secring.gpg)" \
41-
-PossrhUsername="${{ secrets.OSSRH_USERNAMAE }}" \
42-
-PossrhPassword="${{ secrets.OSSRH_PASSWORD }}"
39+
env:
40+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
41+
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
42+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE }}
43+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY }}
44+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }}
45+
run: ./gradlew jreleaserDeploy
46+
47+
- name: Upload JReleaser outputs
48+
if: always()
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: jreleaser-release
52+
path: |
53+
build/jreleaser/trace.log
54+
build/jreleaser/output.properties
4355
4456
- name: Login to GitHub Container Registry
4557
uses: docker/login-action@v3

.github/workflows/release.yaml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,26 @@ jobs:
3232
- name: Setup Gradle
3333
uses: gradle/actions/setup-gradle@v4
3434

35+
- name: Prepare artifacts in staging-deploy directories
36+
run: ./gradlew publish
37+
3538
- name: Upload scalardl-ledger, scalardl-java-client-sdk, scalardl-common, and scalardl-rpc to Maven Central Repository
36-
run: |
37-
echo "${{secrets.SIGNING_SECRET_KEY_RING}}" | base64 -d > /tmp/secring.gpg
38-
./gradlew publish \
39-
-Pversion=${{ steps.version.outputs.version }} \
40-
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}" \
41-
-P'signing.password'="${{ secrets.SIGNING_PASSWORD }}" \
42-
-Psigning.secretKeyRingFile="$(echo /tmp/secring.gpg)" \
43-
-PossrhUsername="${{ secrets.OSSRH_USERNAMAE }}" \
44-
-PossrhPassword="${{ secrets.OSSRH_PASSWORD }}"
39+
env:
40+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
41+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
42+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE }}
43+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY }}
44+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }}
45+
run: ./gradlew jreleaserDeploy
46+
47+
- name: Upload JReleaser outputs
48+
if: always()
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: jreleaser-release
52+
path: |
53+
build/jreleaser/trace.log
54+
build/jreleaser/output.properties
4555
4656
- name: Login to GitHub Container Registry
4757
uses: docker/login-action@v3

build.gradle

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
plugins {
22
id("com.diffplug.spotless") version "6.13.0"
3+
id("org.jreleaser") version "1.19.0"
34
}
45

6+
ext {
7+
projectGroup = 'com.scalar-labs'
8+
projectVersion = '3.10.3-SNAPSHOT'
9+
}
10+
11+
group = projectGroup
12+
version = projectVersion
13+
514
subprojects {
615
apply plugin: 'java'
716
apply plugin: 'eclipse'
@@ -10,7 +19,8 @@ subprojects {
1019
apply plugin: 'java-library-distribution'
1120
apply plugin: 'com.diffplug.spotless'
1221

13-
project.version = '3.10.3-SNAPSHOT'
22+
group = projectGroup
23+
project.version = projectVersion
1424

1525
ext {
1626
grpcVersion = '1.68.1'
@@ -78,8 +88,6 @@ subprojects {
7888
sourceCompatibility = 1.8
7989
targetCompatibility = 1.8
8090

81-
group = "com.scalar-labs"
82-
8391
distZip {
8492
archiveFileName = "${project.name}.zip"
8593
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@@ -106,3 +114,39 @@ subprojects {
106114
executable "${rootDir}/scripts/docker/lint.sh"
107115
}
108116
}
117+
118+
jreleaser {
119+
gitRootSearch = true
120+
121+
signing {
122+
active = 'ALWAYS'
123+
armored = true
124+
}
125+
126+
deploy {
127+
maven {
128+
def stagingRepositories = ['client/build/staging-deploy',
129+
'common/build/staging-deploy',
130+
'ledger/build/staging-deploy',
131+
'rpc/build/staging-deploy']
132+
mavenCentral {
133+
'release-deploy' {
134+
active = 'RELEASE'
135+
url = 'https://central.sonatype.com/api/v1/publisher'
136+
stagingRepositories.each { stagingRepository(it) }
137+
}
138+
}
139+
nexus2 {
140+
'snapshot-deploy' {
141+
active = 'SNAPSHOT'
142+
snapshotUrl = 'https://central.sonatype.com/repository/maven-snapshots/'
143+
applyMavenCentralRules = true
144+
snapshotSupported = true
145+
closeRepository = true
146+
releaseRepository = true
147+
stagingRepositories.each { stagingRepository(it) }
148+
}
149+
}
150+
}
151+
}
152+
}

client/archive.gradle

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'maven-publish'
2-
apply plugin: 'signing'
32

43
publishing {
54
publications {
@@ -42,17 +41,7 @@ publishing {
4241
}
4342
repositories {
4443
maven {
45-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
46-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
47-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
48-
credentials {
49-
username = "${ossrhUsername}"
50-
password = "${ossrhPassword}"
51-
}
44+
url = layout.buildDirectory.dir('staging-deploy')
5245
}
5346
}
5447
}
55-
56-
signing {
57-
sign publishing.publications.mavenJava
58-
}

common/archive.gradle

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'maven-publish'
2-
apply plugin: 'signing'
32

43
publishing {
54
publications {
@@ -40,17 +39,7 @@ publishing {
4039
}
4140
repositories {
4241
maven {
43-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
44-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
45-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
46-
credentials {
47-
username = "${ossrhUsername}"
48-
password = "${ossrhPassword}"
49-
}
42+
url = layout.buildDirectory.dir('staging-deploy')
5043
}
5144
}
5245
}
53-
54-
signing {
55-
sign publishing.publications.mavenJava
56-
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.6-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

ledger/archive.gradle

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'maven-publish'
2-
apply plugin: 'signing'
32

43
publishing {
54
publications {
@@ -40,17 +39,7 @@ publishing {
4039
}
4140
repositories {
4241
maven {
43-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
44-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
45-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
46-
credentials {
47-
username = "${ossrhUsername}"
48-
password = "${ossrhPassword}"
49-
}
42+
url = layout.buildDirectory.dir('staging-deploy')
5043
}
5144
}
5245
}
53-
54-
signing {
55-
sign publishing.publications.mavenJava
56-
}

rpc/archive.gradle

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'maven-publish'
2-
apply plugin: 'signing'
32

43
publishing {
54
publications {
@@ -40,17 +39,7 @@ publishing {
4039
}
4140
repositories {
4241
maven {
43-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
44-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
45-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
46-
credentials {
47-
username = "${ossrhUsername}"
48-
password = "${ossrhPassword}"
49-
}
42+
url = layout.buildDirectory.dir('staging-deploy')
5043
}
5144
}
5245
}
53-
54-
signing {
55-
sign publishing.publications.mavenJava
56-
}

0 commit comments

Comments
 (0)