Support pinning java-version as "latest"#1093
Merged
Merged
Conversation
Add a `latest` alias for the `java-version` input that floats to the newest available stable (GA) release. It is normalized to the SemVer wildcard at the base-installer layer and always resolves from remote (like `check-latest: true`). List-based distributions resolve it automatically via the existing newest-first matching. Corretto selects its newest available major; Oracle and GraalVM look up the newest GA major via the Adoptium API and request it, failing with an actionable error if that major isn't published yet. The jdkfile distribution rejects `latest`. Closes #832 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for specifying java-version: latest in actions/setup-java, allowing workflows to float to the newest stable (GA) Java major release while ensuring the version is resolved from remote metadata (not a potentially stale runner toolcache).
Changes:
- Introduces a
latestalias normalized in the base installer layer and forces remote resolution even when a cached version exists. - Implements
latestbehavior for distributions that require a concrete major (notably oracle/graalvm via Adoptium “available releases”, corretto via its own index, and rejects for jdkfile). - Updates docs/metadata and adds/extends test coverage for the new alias and its distribution-specific behavior.
Show a summary per file
| File | Description |
|---|---|
| src/util.ts | Adds helper to resolve the newest GA major via Adoptium’s available_releases API. |
| src/setup-java.ts | Ensures toolchains receive the resolved version (not the literal latest). |
| src/distributions/oracle/installer.ts | Resolves latest to a concrete major via Adoptium, with an actionable error if Oracle hasn’t published yet. |
| src/distributions/local/installer.ts | Rejects latest for jdkfile installs (local file). |
| src/distributions/graalvm/installer.ts | Resolves latest to a major via Adoptium and improves “not yet available” messaging for Oracle-hosted GraalVM. |
| src/distributions/corretto/installer.ts | Resolves latest to the newest major present in Corretto’s index. |
| src/distributions/base-installer.ts | Adds latest tracking and ensures latest bypasses the toolcache short-circuit. |
| README.md | Documents the latest alias semantics and distribution-specific behavior/limitations. |
| action.yml | Updates java-version input description to mention the latest alias. |
| tests/util.test.ts | Adds unit tests for the new Adoptium-based major resolver. |
| tests/distributors/temurin-installer.test.ts | Verifies latest normalizes to wildcard and resolves to newest available version. |
| tests/distributors/oracle-installer.test.ts | Tests latest major resolution via Adoptium and “not yet available” behavior. |
| tests/distributors/local-installer.test.ts | Tests rejection of latest for jdkfile. |
| tests/distributors/graalvm-installer.test.ts | Tests latest major resolution via Adoptium and “not yet available” behavior. |
| tests/distributors/corretto-installer.test.ts | Tests latest resolution to the newest available Corretto major. |
| tests/distributors/base-installer.test.ts | Tests that latest forces remote resolution and normalizes correctly. |
| dist/setup/index.js | Bundled output update reflecting source changes. |
| dist/cleanup/index.js | Bundled output update reflecting source changes. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 16/18 changed files
- Comments generated: 2
- Review effort level: Low
GraalVM Community publishes its releases on GitHub, so the `latest` alias now matches against that real release list using the SemVer wildcard instead of asking the Adoptium API for the newest GA major. This prevents `latest` from hard-failing when GraalVM lags behind a freshly released Java major (e.g. Adoptium reports 26 before GraalVM ships it). Oracle GraalVM has no listing endpoint, so it keeps deriving the newest major from Adoptium and errors clearly if that major is not yet published. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ava-version-latest # Conflicts: # __tests__/distributors/base-installer.test.ts
…ava-version-latest
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Inputs like 'latest-ea' had their '-ea' suffix stripped and fell through to the generic SemVer validation, failing with a confusing "'latest' is not valid SemVer" message even though 'latest' is supported. Add an explicit guard so any 'latest*' value other than exactly 'latest' throws a targeted error explaining that 'latest' resolves GA releases only and cannot be combined with '-ea' or other qualifiers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Adds a
latestalias for thejava-versioninput so workflows can float to the newest available stable (GA) Java release without pinning a specific major. This future-proofs CI pipelines and matches thelatestconvention other ecosystems (for example Go) already offer.The alias is normalized to the SemVer wildcard at the base-installer layer and always resolves from remote (behaves like
check-latest: true), so it never returns a stale version that happens to be pre-cached on the runner.Resolution by distribution family:
latestuses the Adoptium API only to determine the newest GA major version number, then downloads that major's binary from the Oracle / GraalVM servers. If those servers have not published the resolved major yet, the action fails with an actionable error asking for a concrete version.latestsince it installs from a local file.latestis supported only through thejava-versioninput (notjava-version-file) and resolves GA releases only (it cannot be combined with-ea). Toolchains configuration receives the resolved version rather than the literallatest.Related issue:
Fixes: #832
Check list:
npm run checklocally (format, lint, build, test) and all checks pass.