Skip to content

feat: expose cache-primary-key output (#597) - #1088

Merged
brunoborges merged 5 commits into
mainfrom
brunoborges-psychic-meme
Jul 9, 2026
Merged

feat: expose cache-primary-key output (#597)#1088
brunoborges merged 5 commits into
mainfrom
brunoborges-psychic-meme

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

What

Exposes the primary cache key computed by the caching logic as a new cache-primary-key action output.

Closes #597.

Why

Today the action computes a primary cache key internally (setup-java-<os>-<arch>-<packageManager>-<hash>) but never surfaces it. Users who want to compose the built-in setup-java caching with actions/cache / actions/cache/restore — e.g. to force the same key across dependent jobs — have no way to reference it. This exposes it as an output, mirroring what actions/setup-node and actions/cache already do.

Changes

  • src/cache.ts: set the cache-primary-key output in restore()
  • action.yml: declare the new cache-primary-key output
  • README.md: document the new output
  • __tests__/cache.test.ts: assert the output is set
  • dist/: rebuild

Notes

  • Non-breaking, purely additive.
  • The output is empty when caching is not enabled (the action only computes/sets it inside restore(), which runs only when cache: is set).
  • A backport of this change to releases/v5 is in a separate PR.

Testing

  • npm test (cache suite: 32/32 passing)
  • lint + format-check clean

Expose the primary cache key computed by the caching logic as a new
`cache-primary-key` action output, so workflows can compose the built-in
setup-java cache key with actions/cache or actions/cache/restore across
steps and dependent jobs.

- src/cache.ts: set the `cache-primary-key` output in restore()
- action.yml: declare the new output
- README.md: document the new output
- __tests__/cache.test.ts: assert the output is set
- dist: rebuild

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@brunoborges
brunoborges requested a review from a team as a code owner July 8, 2026 18:59
Copilot AI review requested due to automatic review settings July 8, 2026 18:59
Copilot AI reviewed