Skip to content

Commit 1d93d8d

Browse files
authored
Add jreleaser plugin for deployment (#172)
* Add jreleaser plugin for deployment * fix document * fix a description of the deployment guide * address comment - remove an useless plugin, reuse a secret
1 parent b79a2e3 commit 1d93d8d

File tree

4 files changed

+62
-36
lines changed

4 files changed

+62
-36
lines changed

.github/workflows/publish.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ jobs:
3030
run: ./gradlew clean build
3131

3232
- name: Publish artifacts
33-
run: ./gradlew publish
33+
run: ./gradlew jreleaserConfig publish jreleaserDeploy
3434
env:
35-
OSSRH_USERNAME: ${{ secrets.OSSRH_USER_NAME }}
36-
OSSRH_PASSWORD: ${{ secrets.OSSRH_USER_PASSWORD }}
37-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
38-
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
35+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
36+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
37+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
38+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_CENTRAL_USERNAME }}
39+
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_CENTRAL_USERNAME }}
40+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_CENTRAL_USERNAME }}
41+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_CENTRAL_USERNAME }}
42+
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ repositories {
1313

1414
dependencies {
1515
implementation "io.spring.gradle:dependency-management-plugin:1.1.5"
16+
implementation "org.jreleaser:org.jreleaser.gradle.plugin:1.19.0"
1617
}

buildSrc/src/main/groovy/spring.jdbc.plus.maven-publish-conventions.gradle

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,57 @@
11
plugins {
22
id "maven-publish"
3-
id "signing"
3+
id 'org.jreleaser'
44
}
55

66
group = "com.navercorp.spring"
77
version = "3.5.0"
88

9+
jreleaser {
10+
release {
11+
github {
12+
skipRelease = true
13+
}
14+
}
15+
gitRootSearch = true
16+
signing {
17+
active = 'ALWAYS'
18+
armored = true
19+
verify = true
20+
}
21+
deploy {
22+
maven {
23+
mavenCentral {
24+
'release-deploy' {
25+
active = 'RELEASE'
26+
url = 'https://central.sonatype.com/api/v1/publisher'
27+
sign = true
28+
stagingRepository('build/staging-deploy')
29+
}
30+
}
31+
// The following configuration is applied when the version matches the "*-SNAPSHOT" pattern.
32+
nexus2 {
33+
'snapshot-deploy' {
34+
active = 'SNAPSHOT'
35+
snapshotUrl = 'https://central.sonatype.com/repository/maven-snapshots/'
36+
applyMavenCentralRules = true
37+
snapshotSupported = true
38+
closeRepository = true
39+
releaseRepository = false
40+
stagingRepository('build/staging-deploy')
41+
}
42+
}
43+
}
44+
}
45+
}
46+
947
publishing {
1048
publications {
1149
mavenJava(MavenPublication) {
1250
from components.java
1351

1452
repositories {
1553
maven {
16-
def ossrhUsername = System.getenv("OSSRH_USERNAME")
17-
def ossrhPassword = System.getenv("OSSRH_PASSWORD")
18-
19-
credentials {
20-
username ossrhUsername
21-
password ossrhPassword
22-
}
23-
24-
def releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
25-
def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
26-
url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
54+
url = layout.buildDirectory.dir("staging-deploy")
2755
}
2856
}
2957

@@ -77,16 +105,3 @@ publishing {
77105
}
78106
}
79107
}
80-
81-
signing {
82-
def signingKey = findProperty("signingKey")
83-
def signingPassword = findProperty("signingPassword")
84-
85-
useInMemoryPgpKeys(signingKey, signingPassword)
86-
87-
sign publishing.publications.mavenJava
88-
}
89-
90-
tasks.withType(Sign) {
91-
onlyIf { !version.endsWith("SNAPSHOT") }
92-
}

doc/deployment_guide.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44

55
1. Go to the "[Publish Artifacts](https://github.com/naver/spring-jdbc-plus/actions/workflows/publish.yml)" action.
66
2. Enter the tag, branch, or commit ID, and run the action.
7-
3. You can verify the success of the deployment on [oss.sonatype.org](https://oss.sonatype.org/#stagingRepositories).
7+
3. You can verify the success of the deployment on [central.sonatype.org](https://central.sonatype.com/publishing/deployments).
88

99
### Using a Local Machine
1010

1111
1. Set the following environment variables before publishing:
12-
- `ORG_GRADLE_PROJECT_signingKey`: Enter your personal GPG private key. Ensure that line breaks are removed, as shown [here](https://github.com/vanniktech/gradle-maven-publish-plugin/pull/201#discussion_r584270633).
13-
- `ORG_GRADLE_PROJECT_signingPassword`: Enter the password associated with your GPG private key.
14-
- `OSSRH_USERNAME`: Enter your OSSRH username using the generated [Access User Token](https://oss.sonatype.org/#profile;User%20Token).
15-
- `OSSRH_PASSWORD`: Enter your OSSRH password using the generated [Access User Token](https://oss.sonatype.org/#profile;User%20Token).
16-
2. Run `./gradlew clean publish` to complete the publishing process.
12+
- `JRELEASER_MAVENCENTRAL_USERNAME`: Your Sonatype username token. using the generated [Access User Token](https://central.sonatype.com/account).
13+
- `JRELEASER_MAVENCENTRAL_PASSWORD`: Your Sonatype password token. using the generated [Access User Token](https://central.sonatype.com/account).
14+
- `JRELEASER_NEXUS2_USERNAME` (for snapshots): same as JRELEASER_MAVENCENTRAL_USERNAME
15+
- `JRELEASER_NEXUS2_PASSWORD` (for snapshots): same as JRELEASER_MAVENCENTRAL_PASSWORD
16+
- `JRELEASER_GPG_PASSPHRASE`: Your GPG key passphrase.
17+
- `JRELEASER_GPG_PUBLIC_KEY`: Your GPG public key, Base64 encoded. (`gpg --export ${your_key_id} | base64`)
18+
- `JRELEASER_GPG_SECRET_KEY`: Your GPG secret key, Base64 encoded. (`gpg --export-secret-keys ${your_key_id} | base64`)
19+
- `JRELEASER_GITHUB_TOKEN`: Set this to an empty string. It's not used, but the variable is required by JReleaser.
20+
2. Run `./gradlew jreleaserConfig` to verify your configuration.
21+
3. Run `./gradlew clean build publish` to build the artifact locally.
22+
4. Run `./gradlew jreleaserDeploy` to publish and release your artifact to Maven Central

0 commit comments

Comments
 (0)