Skip to content

Commit 4d228d5

Browse files
committed
Use JReleaser to release artifacts in Maven Central
1 parent e7224b9 commit 4d228d5

File tree

7 files changed

+98
-74
lines changed

7 files changed

+98
-74
lines changed

.github/workflows/release-snapshot.yaml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,28 @@ jobs:
3030
VERSION=$(./gradlew :core:properties -q | grep "version:" | awk '{print $2}')
3131
echo "version=${VERSION}" >> $GITHUB_OUTPUT
3232
33-
- name: Upload SNAPSHOT versions for scalardb, scalardb-schema-loader, scalardb-data-loader-core, and scalardb-integration-test to Maven Snapshot Repository
33+
- name: Prepare SNAPSHOT versions of artifacts in staging-deploy directories
3434
if: contains(steps.version.outputs.version, '-SNAPSHOT')
35-
run: |
36-
echo "${{secrets.SIGNING_SECRET_KEY_RING}}" | base64 -d > ~/.gradle/secring.gpg
37-
./gradlew publish \
38-
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}" \
39-
-P'signing.password'="${{ secrets.SIGNING_PASSWORD }}" \
40-
-Psigning.secretKeyRingFile="$(echo ~/.gradle/secring.gpg)" \
41-
-PossrhUsername="${{ secrets.OSSRH_USERNAMAE }}" \
42-
-PossrhPassword="${{ secrets.OSSRH_PASSWORD }}"
35+
run: ./gradlew publish
36+
37+
- name: Upload SNAPSHOT versions of artifacts to Maven Snapshot repository
38+
if: contains(steps.version.outputs.version, '-SNAPSHOT')
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/upload-artifacts.yaml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ jobs:
4343
- name: Setup Gradle
4444
uses: gradle/actions/setup-gradle@v4
4545

46+
- name: Prepare artifacts in staging-deploy directories
47+
run: ./gradlew publish
48+
49+
- name: Upload artifacts to Maven Central Repository
50+
env:
51+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
52+
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
53+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE }}
54+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY }}
55+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }}
56+
run: ./gradlew jreleaserDeploy
57+
58+
- name: Upload JReleaser outputs
59+
if: always()
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: jreleaser-release
63+
path: |
64+
build/jreleaser/trace.log
65+
build/jreleaser/output.properties
66+
4667
- name: Login to GitHub Container Registry
4768
uses: docker/login-action@v3
4869
with:
@@ -57,13 +78,3 @@ jobs:
5778
run: |
5879
docker push ghcr.io/scalar-labs/scalardb-schema-loader:${{ steps.version.outputs.version }}
5980
docker push ghcr.io/scalar-labs/scalardb-data-loader-cli:${{ steps.version.outputs.version }}
60-
61-
- name: Upload scalardb, scalardb-schema-loader, scalardb-data-loader-core, and scalardb-integration-test to Maven Central Repository
62-
run: |
63-
echo "${{secrets.SIGNING_SECRET_KEY_RING}}" | base64 -d > ~/.gradle/secring.gpg
64-
./gradlew publish \
65-
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}" \
66-
-P'signing.password'="${{ secrets.SIGNING_PASSWORD }}" \
67-
-Psigning.secretKeyRingFile="$(echo ~/.gradle/secring.gpg)" \
68-
-PossrhUsername="${{ secrets.OSSRH_USERNAMAE }}" \
69-
-PossrhPassword="${{ secrets.OSSRH_PASSWORD }}"

build.gradle

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id "org.jreleaser" version "1.19.0"
3+
}
4+
15
buildscript {
26
repositories {
37
maven {
@@ -9,6 +13,14 @@ buildscript {
913
}
1014
}
1115

16+
ext {
17+
projectGroup = 'com.scalar-labs'
18+
projectVersion = '4.0.0-SNAPSHOT'
19+
}
20+
21+
group = projectGroup
22+
version = projectVersion
23+
1224
subprojects {
1325
apply plugin: 'java'
1426
apply plugin: 'eclipse'
@@ -18,7 +30,7 @@ subprojects {
1830
apply plugin: 'com.diffplug.spotless'
1931
apply plugin: 'com.scalar.db.jdk-configuration'
2032

21-
project.version = '4.0.0-SNAPSHOT'
33+
project.version = projectVersion
2234

2335
ext {
2436
guiceVersion = '5.1.0'
@@ -35,7 +47,7 @@ subprojects {
3547
sqlserverDriverVersion = '12.8.1.jre8'
3648
sqliteDriverVersion = '3.50.2.0'
3749
yugabyteDriverVersion = '42.7.3-yb-4'
38-
db2DriverVersion= '12.1.2.0'
50+
db2DriverVersion = '12.1.2.0'
3951
mariadDbDriverVersion = '3.5.4'
4052
picocliVersion = '4.7.7'
4153
commonsTextVersion = '1.13.1'
@@ -66,7 +78,7 @@ subprojects {
6678
testLogging.showStandardStreams = true
6779
}
6880

69-
group = "com.scalar-labs"
81+
group = projectGroup
7082

7183
java {
7284
withJavadocJar()
@@ -92,3 +104,40 @@ subprojects {
92104
}
93105
}
94106

107+
jreleaser {
108+
gitRootSearch = true
109+
110+
signing {
111+
active = 'ALWAYS'
112+
armored = true
113+
}
114+
115+
deploy {
116+
maven {
117+
mavenCentral {
118+
sonatype {
119+
active = 'RELEASE'
120+
url = 'https://central.sonatype.com/api/v1/publisher'
121+
stagingRepository('core/build/staging-deploy')
122+
stagingRepository('integration-test/build/staging-deploy')
123+
stagingRepository('schema-loader/build/staging-deploy')
124+
stagingRepository('data-loader/core/build/staging-deploy')
125+
}
126+
}
127+
nexus2 {
128+
'snapshot-deploy' {
129+
active = 'SNAPSHOT'
130+
snapshotUrl = 'https://central.sonatype.com/repository/maven-snapshots/'
131+
applyMavenCentralRules = true
132+
snapshotSupported = true
133+
closeRepository = true
134+
releaseRepository = true
135+
stagingRepository('core/build/staging-deploy')
136+
stagingRepository('integration-test/build/staging-deploy')
137+
stagingRepository('schema-loader/build/staging-deploy')
138+
stagingRepository('data-loader/core/build/staging-deploy')
139+
}
140+
}
141+
}
142+
}
143+
}

core/build.gradle

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ plugins {
22
id 'com.github.spotbugs-base' version "${spotbugsPluginVersion}"
33
id 'net.ltgt.errorprone' version "${errorpronePluginVersion}"
44
id 'maven-publish'
5-
id 'signing'
65
id 'base'
76
}
87

@@ -320,18 +319,7 @@ publishing {
320319
}
321320
repositories {
322321
maven {
323-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
324-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
325-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
326-
credentials {
327-
username = project.properties['ossrhUsername'] ?: ""
328-
password = project.properties['ossrhPassword'] ?: ""
329-
}
322+
url = layout.buildDirectory.dir('staging-deploy')
330323
}
331324
}
332325
}
333-
334-
signing {
335-
required { project.gradle.taskGraph.hasTask("publish") }
336-
sign publishing.publications.mavenJava
337-
}

data-loader/core/build.gradle

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ plugins {
33
id 'com.github.johnrengelman.shadow' version "${shadowPluginVersion}"
44
id 'com.github.spotbugs' version "${spotbugsPluginVersion}"
55
id 'maven-publish'
6-
id 'signing'
76
id 'base'
87
}
98

@@ -89,18 +88,7 @@ publishing {
8988
}
9089
repositories {
9190
maven {
92-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
93-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
94-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
95-
credentials {
96-
username = project.properties['ossrhUsername'] ?: ""
97-
password = project.properties['ossrhPassword'] ?: ""
98-
}
91+
url = layout.buildDirectory.dir('staging-deploy')
9992
}
10093
}
10194
}
102-
103-
signing {
104-
required { project.gradle.taskGraph.hasTask("publish") }
105-
sign publishing.publications.mavenJava
106-
}

integration-test/build.gradle

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ plugins {
22
id 'com.github.spotbugs' version "${spotbugsPluginVersion}"
33
id 'net.ltgt.errorprone' version "${errorpronePluginVersion}"
44
id 'maven-publish'
5-
id 'signing'
65
id 'base'
76
}
87

@@ -100,18 +99,7 @@ publishing {
10099
}
101100
repositories {
102101
maven {
103-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
104-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
105-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
106-
credentials {
107-
username = project.properties['ossrhUsername'] ?: ""
108-
password = project.properties['ossrhPassword'] ?: ""
109-
}
102+
url = layout.buildDirectory.dir('staging-deploy')
110103
}
111104
}
112105
}
113-
114-
signing {
115-
required { project.gradle.taskGraph.hasTask("publish") }
116-
sign publishing.publications.mavenJava
117-
}

schema-loader/build.gradle

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ plugins {
33
id 'com.github.johnrengelman.shadow' version "${shadowPluginVersion}"
44
id 'com.github.spotbugs' version "${spotbugsPluginVersion}"
55
id 'maven-publish'
6-
id 'signing'
76
id 'base'
87
}
98

@@ -135,18 +134,7 @@ publishing {
135134
}
136135
repositories {
137136
maven {
138-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
139-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
140-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
141-
credentials {
142-
username = project.properties['ossrhUsername'] ?: ""
143-
password = project.properties['ossrhPassword'] ?: ""
144-
}
137+
url = layout.buildDirectory.dir('staging-deploy')
145138
}
146139
}
147140
}
148-
149-
signing {
150-
required { project.gradle.taskGraph.hasTask("publish") }
151-
sign publishing.publications.mavenJava
152-
}

0 commit comments

Comments
 (0)