Skip to content

Releases are published to Maven Central through the Central Portal from a GitHub release - #37

Open
augustak wants to merge 2 commits into
masterfrom
central-portal-publishing
Open

augustak wants to merge 2 commits into
masterfrom
central-portal-publishing

Conversation

@augustak

@augustak augustak commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

make publish uploaded to OSSRH (oss.sonatype.org), which Sonatype shut down in June 2025, so no new version can be released until publishing goes through the Central Portal. This PR moves publishing there and runs it from GitHub Actions, so a release no longer depends on one person's machine and credentials.

How a release works

  1. Merge a PR that bumps version in gradle.properties.
  2. Publish a GitHub release tagged v<version>, such as v4.0.1.
  3. The Publish workflow checks that the tag matches the version and is on a commit on master. It then builds and signs the jar, sources, javadoc and POM into a bundle (make bundle), uploads it to the Central Portal API, and waits until Maven Central reports it as published (upload-to-central.sh).

make publish runs the same steps from a local machine, given the same secrets as environment variables. Afterwards, push the v<version> tag by hand.

If a release fails, the README says how to recover: check the Portal first, then delete the release and its tag, merge the fix, and publish again.

Why not trusted publishing

Maven Central has no OIDC trusted publishing like PyPI's or npm's. The Central Portal's only credential is a user token. Instead, the token and signing key are stored only in a maven-central GitHub environment, the publish job is the only one that uses that environment, and it has read-only repository permissions. Adding required reviewers on the environment would also make every release wait for approval.

Changes

  • build.gradle: the maven plugin (deprecated in Gradle 6, removed in 7) and uploadArchives are replaced with maven-publish, which writes the signed artifacts to build/staging-deploy. The signing key can be passed in memory (ORG_GRADLE_PROJECT_signingKey / signingPassword), and the old signing.* properties in ~/.gradle/gradle.properties still work. The POM matches 4.0.0, except that test dependencies are no longer listed and it now points to the Gradle module metadata.
  • upload-to-central.sh: uploads once with publishingType=AUTOMATIC, then polls the deployment status until it is PUBLISHED (exit 0) or FAILED (exit 1, printing the Portal's errors), giving up after an hour. A failed status check (a timeout, a 5xx, or a body that isn't JSON) is retried until that deadline, since the Portal goes on with the deployment anyway and would reject a second upload of the same version. The token reaches curl through a file descriptor, so it never appears in the process list.
  • .github/workflows/publish.yml, Makefile and the README's publishing section.

The release job doesn't run the tests, since they need the mock API in Docker and already run in CI on every PR.

Setup needed before the first release

  • Check whether Sonatype requires a paid Publisher Pro subscription for this SDK. Since October 1, 2026, it requires one for "SDKs, client libraries … maintained by a commercial organization", whatever their license. Either subscribe, or ask central-support@sonatype.com for an exemption.
  • Sign in at https://central.sonatype.com with the account that owned ai.lucidtech on OSSRH and check that the namespace is listed. OSSRH accounts were migrated to the Portal.
  • Generate a user token there, with an expiry date.
  • Create a maven-central environment in this repo's settings, ideally with required reviewers and limited to tags matching v*. Add the secrets CENTRAL_USERNAME and CENTRAL_PASSWORD (the token), plus SIGNING_KEY (ASCII-armored private key) and SIGNING_PASSWORD. 4.0.0 was signed with key E614123FE64036D2, which is still on keyserver.ubuntu.com and keys.openpgp.org, so it can be reused if anyone still has the private key. Otherwise, generate a new key and upload its public key to a keyserver.

Testing

  • With a throwaway GPG key on JDK 8, make bundle built the 4.0.1 bundle containing the jar, sources, javadoc, POM and module. Each has a .asc signature that verifies, plus md5/sha1/sha256/sha512 checksums that match. The jar is still Java 8 bytecode.
  • I ran upload-to-central.sh against a stubbed curl and checked:
    • Success (PENDING → VALIDATING → PUBLISHED) exits 0, including when a 503, a connection failure or an HTML response comes in between.
    • FAILED exits 1 with the Portal's errors.
    • A failed upload exits 1 with the Portal's error, after exactly one upload attempt.
    • The deadline ends polling with exit 1.
    • The token isn't among curl's arguments.
  • I checked the master check against a local repository: it allows a tag on master and refuses one on a branch.
  • Not tested against the real Portal, which needs the token above.

Relation to other PRs and checks

🤖 Generated with Claude Code

…om a GitHub release

OSSRH (oss.sonatype.org), which uploadArchives published to, was shut down in
June 2025. The signed artifacts are now built with maven-publish into a bundle
that upload-to-central.sh uploads to the Central Portal API, waiting until it
is published. Publishing a GitHub release whose tag is the version runs it in
the maven-central environment, which holds the Portal token and signing key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@augustak
augustak force-pushed the central-portal-publishing branch from 7eb2b27 to ad850c5 Compare December 2, 2026 15:29

@augustak augustak left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks good overall. One change I'd make before merging (polling retries, inline), plus two README additions about how releases interact with the tag-based version check from #39.

What I checked

  • Built the bundle on JDK 8 with a throwaway GPG key (make bundle). It has 51 files: the jar, sources, javadoc, POM and module, each with a .asc signature and md5/sha1/sha256/sha512 checksums, all under ai/lucidtech/las-sdk-java/4.0.1/. maven-metadata.xml is correctly left out of the zip.
  • Compared the generated POM with the published 4.0.0 POM. The only differences are the dependency versions from #36, the commons-io groupId fix, the test dependencies that are no longer listed, and the Gradle-metadata marker comment. The dependency scopes are still runtime, as in 4.0.0.
  • There is no settings.gradle, so project.name is the checkout directory's name. Setting artifactId = archivesBaseName explicitly is what keeps the POM and module coordinates las-sdk-java when the checkout directory has another name (mine did). Good.
  • The upload and status endpoints, the bearer-token format and the deploymentState values match the Central Portal API docs.

The description is out of date

  • "the 'Check that version is updated' check fails on purpose": since #38/#39 it passes. build.gradle changes, but no v4.0.1 tag exists yet.
  • "the removed maven plugin": Gradle 6.3 still has it (deprecated). It was removed in 7.0. Replacing it is still right, since OSSRH is gone.

FYI, not for this PR

  • The repo has no tags at all, including none for 4.0.0 and earlier. So until the first release made through this workflow, the #39 check treats every version as unreleased. Pushing v4.0.0 on the commit that was released would make the check trustworthy right away.
  • The public API returns and takes JSONObject (and the HttpClient types), but the dependencies are published with runtime scope, exactly as in 4.0.0. Maven users have to declare org.json themselves. Switching to java-library with api dependencies would fix that. It's an existing problem, so it belongs in a separate change.

Comment thread upload-to-central.sh Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread upload-to-central.sh Resolved

@augustak augustak left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Both PR checks passed. I built the 4.0.1 bundle offline on Java 8 and verified all five signatures, the checksums, and the Java 8 bytecode. I reproduced the polling failure with a stubbed Portal response. Live Portal acceptance remains unverified.

Comment thread upload-to-central.sh Resolved
Comment thread .github/workflows/publish.yml Resolved
Comment thread README.md Resolved
… master

- upload-to-central.sh keeps polling the accepted deployment until the deadline
  when a status check fails, as the Portal goes on publishing it and rejects
  uploading the same version again. The token is passed to curl through a file
  descriptor instead of its command line, and a failed upload prints the
  Portal's error.
- The Publish workflow refuses a release tag on a commit that isn't on master.
- The README says how to recover from a failed release, and to tag a release
  published from a local machine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@augustak

augustak commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Follow-up to the review summary:

Out-of-date description: fixed. It now says the version check passes, since #38/#39 and 4.0.1 has no tag yet, and that the maven plugin is deprecated in Gradle 6 and removed in 7. It also describes the master check, the status retries, and the Publisher Pro item in the setup checklist.

Missing tags for 4.0.0 and earlier: agreed. Pushing v4.0.0 on bf6a0d8 makes the version check trustworthy right away. That commit is byte-for-byte the source of the published 4.0.0 sources jar. It's a change to the repository, not this PR, so it waits for a go-ahead.

runtime scope for dependencies that are part of the public API: agreed that JSONObject and the HttpClient types in the public API make them api dependencies, and that java-library with api would fix this for Maven users. It's an existing problem that changes the published POM, so it belongs in its own change, as you say.

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.

1 participant