Skip to content

Automate release/publish process to public Maven repository - #281

Merged
yhartanto merged 2 commits into
mainfrom
yohan/maven-central-release
Oct 21, 2026
Merged

yhartanto merged 2 commits into
mainfrom
yohan/maven-central-release

Conversation

@yhartanto

Copy link
Copy Markdown
Collaborator

Secrets are now configured at organization level, this allows us to automate release without granting individuals direct acces to the keys.

This PR is providing the new workflow for this. See RELEASING.md for the process to release

@tyvsmith

Copy link
Copy Markdown
Member

Where does this differ from the reference impl https://github.com/uber/h3-java/blob/master/.github/workflows/release.yml and why?

A few that seem missing/different.

  • Seems to be missing github release creation via API (final step of h3 release)
  • Should we handle automatic removal of snapshot suffix?
  • CHangelog/release notes
  • custom signing logic, isn't that just handled in the vannitech release plugin if it's set as an env var?

@yhartanto

Copy link
Copy Markdown
Collaborator Author

List of differences:

Area Reference: H3 Java Current Motif workflow Effect
Automatic trigger Runs when a tag matching v* is pushed. Runs for tags starting with a digit or v followed by a digit, then validates the complete version format. Supports Motif’s existing tags such as 0.4.0-alpha16, plus v0.4.0-alpha16.
Manual run Accepts an optional release_version; otherwise reads the project version. Can modify the version, commit, create a tag, and push to master. Requires an existing release_tag and explicitly checks out that tag. Motif’s version preparation and tagging happen before the workflow runs.
Version validation Reads the version from input or gradle.properties; does not explicitly compare it with the triggering tag. Requires the tag to match VERSION_NAME and rejects snapshots. Prevents publishing a version that differs from the release tag.
Changelog Extracts release notes and requires nonempty content. Requires an exact # <version> heading. Motif checks that the version is listed, but does not check that the section contains release notes.
Build structure Builds native libraries across Linux, Android, Windows, and macOS, then transfers binaries to the publishing job. Checks and publishes the JVM library modules in one Ubuntu job. H3’s Docker builds, native binaries, submodules, and artifact transfers are unnecessary for Motif.
Java versions Uses JDK 17 for native build jobs and JDK 21 for publishing. Installs JDKs 8, 11, and 21; Gradle runs on 21. Matches Motif’s runtime and Kotlin library toolchains.
Publication scope Calls the unqualified publishAndReleaseToMavenCentral task. Calls that task explicitly for eight library modules. Keeps IntelliJ publication tasks out while leaving IntelliJ projects included in the build.
GitHub permissions Uses contents: write to push commits/tags and create a GitHub Release. Uses contents: read and disables persisted checkout credentials. Motif’s workflow publishes Maven artifacts without changing Git history.
GitHub Release Creates a GitHub Release using extracted changelog notes. Writes a GitHub Actions summary only. Motif artifacts appear in Maven Central, but no GitHub Release page is created.
Next development version Contains a commented-out automatic version bump because direct branch pushes are prohibited. Documents preparing the next snapshot through a separate PR. Keeps version changes in the normal PR process.

@yhartanto
yhartanto force-pushed the yohan/maven-central-release branch from 3017a63 to 336e5b9 Compare October 21, 2026 00:01
@tyvsmith

Copy link
Copy Markdown
Member

Thanks for putting this together. Motif already uses the vanniktech plugin (0.34.0), the same setup as NullAway's publish-release.yml, so I think this workflow can shrink to roughly NullAway's size (~40 lines instead of ~145).

Redundant pieces

  • credential presence loop: Gradle already fails when credentials or the signing key are missing
  • unset of an empty signingInMemoryKeyId: NullAway passes the same org secret without this guard and publishes fine
  • ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED and -PsignAllPublications=true: both are already true in gradle.properties
  • CI: 'true': GitHub Actions sets this by default (the xprocessing unshaded classifier check still sees it)
  • spotless + check before publishing: the tagged commit already passed CI on main
  • workflow_dispatch with release_tag: "Re-run job" on the tag-push run covers retries
  • changelog extraction + GitHub Release: fine to keep if we want it, but publishing doesn't need it

The fromEnv toolchain flag and the JDK 8/11 install are needed, since lib targets a JDK 8 toolchain and there's no foojay resolver. Keeping a short tag/VERSION_NAME check like NullAway's also makes sense.

Suggested publish step

- name: Publish
  env:
    ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USER_TOKEN_USERNAME }}
    ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_USER_TOKEN_PASSWORD }}
    ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.PGP_PRIVATE_KEY_ID }}
    ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.PGP_SIGNING_KEY_PRIVATE_KEY }}
    ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PGP_SIGNING_KEY_PASSWORD }}
  run: ./gradlew publishToMavenCentral -Porg.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64

Plus, in gradle.properties:

  • add mavenCentralAutomaticPublishing=true so publishToMavenCentral uploads and releases in one step, with no manual Central Portal click
  • remove SONATYPE_HOST=DEFAULT, since 0.34 dropped OSSRH and mavenCentralPublishing=true replaces it

Risks

  • five artifacts stop publishing: motif-viewmodel, motif-xprocessing, motif-xprocessing-testing, motif-intellij, and motif-ast-intellij are on Central at every version through 0.4.0-alpha15. The MAVEN_MODULES list leaves all five out, and the PR only explains the IntelliJ ones.
    • if dropping them is intentional, remove com.vanniktech.maven.publish from those modules' build.gradle so a plain root publishToMavenCentral does the right thing and the YAML needs no module list
    • if not, publish everything, as the old ./gradlew publish did
  • snapshot uploads never run (existing, unrelated): ci.yml gates the snapshot upload on refs/heads/master, but the default branch is main. Worth fixing while we're here.

Comment drafted with an AI agent.

@yhartanto

Copy link
Copy Markdown
Collaborator Author

@tyvsmith updated as per feedback

@yhartanto
yhartanto force-pushed the yohan/maven-central-release branch from 6d45889 to fd0dfdb Compare October 21, 2026 18:11
Create a GitHub Release from the matching CHANGELOG.md section after
publishing, and fail before publishing when that section is missing.
@tyvsmith
tyvsmith requested a balanced review from Copilot October 21, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@tyvsmith
tyvsmith self-requested a review October 21, 2026 18:28

@tyvsmith tyvsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good after CI passes.

@tyvsmith

Copy link
Copy Markdown
Member

Separately, we should look into putting up manual dispatch support that can create tag and take the version number as input. Will give maintainers a once click release from the actions page.

@yhartanto
yhartanto merged commit 76124bd into main Oct 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants