Skip to content

Support pinning java-version as "latest"#1093

Merged
brunoborges merged 7 commits into
mainfrom
brunoborges-support-java-version-latest
Jul 10, 2026
Merged

Support pinning java-version as "latest"#1093
brunoborges merged 7 commits into
mainfrom
brunoborges-support-java-version-latest

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

Description:

Adds a latest alias for the java-version input so workflows can float to the newest available stable (GA) Java release without pinning a specific major. This future-proofs CI pipelines and matches the latest convention 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:

  • List-based distributions (temurin, zulu, liberica, sapmachine, semeru, dragonwell, kona, adopt, jetbrains, microsoft, graalvm-community) resolve automatically via the existing newest-first matching, so no per-distribution changes were needed.
  • corretto matches on an exact major, so it selects its own newest available major.
  • oracle and graalvm build download URLs from a concrete major and have no "list all releases" endpoint. For those, latest uses 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.
  • jdkfile rejects latest since it installs from a local file.

latest is supported only through the java-version input (not java-version-file) and resolves GA releases only (it cannot be combined with -ea). Toolchains configuration receives the resolved version rather than the literal latest.

Related issue:
Fixes: #832

Check list:

  • Ran npm run check locally (format, lint, build, test) and all checks pass.
  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

brunoborges and others added 2 commits July 9, 2026 15:20
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>
Copilot AI review requested due to automatic review settings July 9, 2026 19:32
@brunoborges brunoborges requested a review from a team as a code owner July 9, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 latest alias normalized in the base installer layer and forces remote resolution even when a cached version exists.
  • Implements latest behavior 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

Comment thread src/distributions/base-installer.ts
Comment thread src/distributions/corretto/installer.ts
brunoborges and others added 5 commits July 9, 2026 15:44
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
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>
@brunoborges brunoborges merged commit 174d4b5 into main Jul 10, 2026
406 checks passed
@brunoborges brunoborges deleted the brunoborges-support-java-version-latest branch July 10, 2026 00:11
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.

Support pinning java-version as "latest"

2 participants