Skip to content

ci(java): add the Maven Central release workflow - #18

Merged
mwaisaida-13 merged 3 commits into
release-2from
java/release-workflow
Sep 29, 2026
Merged

mwaisaida-13 merged 3 commits into
release-2from
java/release-workflow

Conversation

@mwaisaida-13

Copy link
Copy Markdown
Collaborator

Adds the release pipeline for the Java package, following the Central Portal's Maven publishing guide.

What a java-v* release does

  1. Tests the source on every supported Java version (from java.supported.versions in the pom).
  2. In the maven environment, after approval: verifies the tag matches the pom version, then runs mvn -P release deploy, which signs every artifact, uploads them to the Central Portal, waits for validation and publishes them. Then smoke-tests that the files are served by Maven Central.

Changes

  • java/pom.xml: <developers> and <scm> metadata that Central requires, and a release profile with maven-gpg-plugin and central-publishing-maven-plugin (autoPublish, waitUntil=published). Normal builds are unchanged and never sign.
  • scripts/java_dev.py: verify (tag == java-v + pom version, not a SNAPSHOT, ## [version] present in java/CHANGELOG.md) and smoke (polls Maven Central for the pom, jar, sources, javadoc and signature).
  • .github/workflows/java-release.yml: the workflow above. Fork guard on the repository owner; secrets are scoped to the maven environment.

Verified locally

  • The release profile signs all four artifacts with a throwaway key and every signature verifies.
  • Normal builds produce no signatures.
  • verify rejects a SNAPSHOT version and a mismatched tag; list-supported-versions is unchanged.
  • actionlint is clean.

The upload itself cannot be exercised until the namespace is approved on the Portal.

Before the first release

  • Namespace approval for software.amazon.elasticache.
  • Release commit: bump 0.1.0-SNAPSHOT to the release version in the poms and add the CHANGELOG entry.

mwaisaida-13 added 2 commits September 28, 2026 15:03
- pom.xml: add the developer and scm metadata Maven Central requires, and
  a release profile that signs every artifact and publishes through the
  Central Portal. Normal builds never sign.
- java_dev.py: add verify (tag matches a non-SNAPSHOT pom version with a
  CHANGELOG entry) and smoke (polls Maven Central for the published files).
- java-release.yml: on a java-v* release, test every supported Java
  version, then sign and publish from the maven environment and smoke-test
  Maven Central.
verify now also requires java/examples/pom.xml and
java/integration-tests/pom.xml to depend on the release version, since
the examples are not built by the release workflow. The developers block
uses the same fields as other AWS libraries on Maven Central.
@mwaisaida-13
mwaisaida-13 marked this pull request as ready for review September 28, 2026 14:25
server-id: central
server-username: CENTRAL_TOKEN_USERNAME
server-password: CENTRAL_TOKEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

setup-java@v4.7.1 defaults gpg-passphrase to the environment variable GPG_PASSPHRASE and writes that name into Maven settings. The publish step only defines MAVEN_GPG_PASSPHRASE, so a passphrase-protected key cannot be unlocked.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With bestPractices=true, maven-gpg-plugin 3.2.8 reads the passphrase from the MAVEN_GPG_PASSPHRASE environment variable directly and ignores the gpg.passphrase server in settings.xml, so this worked locally as written. But to ensure the two agree, will add setup-java to get gpg-passphrase: MAVEN_GPG_PASSPHRASE. thank you!

Comment thread scripts/java_dev.py Outdated
base = (
f"{CENTRAL}/{group.replace('.', '/')}/{artifact}/{version}/{artifact}-{version}"
)
files = [".pom", ".jar", "-sources.jar", "-javadoc.jar", ".jar.asc"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider also requiring .pom.asc, -sources.jar.asc, and -javadoc.jar.asc so the post-publish verification covers the complete release.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ack, the smoke test now requires the .asc for all four artifacts, thank you!

- setup-java's gpg-passphrase names MAVEN_GPG_PASSPHRASE explicitly, so the
  settings.xml it writes and maven-gpg-plugin read the same variable.
- The smoke test requires the signature of every artifact, not just the jar.
# Tag must match the pom version, which must not be a SNAPSHOT, and the
# CHANGELOG must have an entry.
- name: Verify the tag matches the pom version
run: python3 scripts/java_dev.py verify "$GITHUB_REF_NAME"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This validation runs only after a reviewer approves the maven environment because it is inside publish. A mistyped tag or missed version bump therefore runs the full matrix and requests approval before failing. Please move this step into versions, which already checks out the repository and has Python 3, so invalid releases fail before the matrix and environment gate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ack, will add guard as follow ups


- name: Build and test
run: mvn --batch-mode --no-transfer-progress install

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The release matrix skips the documentation examples. java.yml runs mvn --file examples/pom.xml verify after install, and verify now requires examples/pom.xml to use the release version. Please add the same step here between Build and test and the integration tests so the release artifact is checked against the examples before publishing.

@edlng edlng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

comments non-blocking though!

@mwaisaida-13
mwaisaida-13 merged commit 97ff7fd into release-2 Sep 29, 2026
23 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