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 ownerJuly 8, 2026 18:59
CopilotAI review requested due to automatic review settings July 8, 2026 18:59

CopilotAI 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

This PR adds a new action output, cache-primary-key, to expose the primary dependency cache key computed by actions/setup-java, enabling users to reuse the exact same key in later steps or dependent jobs (e.g., with actions/cache / actions/cache/restore).

Changes:

  • Set a new cache-primary-key output during cache restore.
  • Declare and document the new output in action.yml and README.md.
  • Add test coverage for the new output and rebuild dist/ bundles.
Show a summary per file
FileDescription
src/cache.tsSets the new cache-primary-key output during restore() after computing the primary key.
action.ymlDeclares cache-primary-key as an action output with a description.
README.mdDocuments the new output and its intended usage with actions/cache tooling.
tests/cache.test.tsAdds an assertion that cache-primary-key is set during restore.
dist/setup/index.jsRebuilt bundle reflecting the new output behavior in the main action.
dist/cleanup/index.jsRebuilt bundle reflecting the updated cache module code included in the post action bundle.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/6 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment threadsrc/cache.ts Outdated
Comment threadREADME.md Outdated
Comment threadaction.yml Outdated
brunoborgesand others added 3 commits July 8, 2026 15:03
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
brunoborges added a commit that referenced this pull request Jul 8, 2026
Port the review feedback from the main-line PR (#1088) into the v5 backport:
- src/cache.ts: use the STATE_CACHE_PRIMARY_KEY constant for the output name
instead of a duplicated string literal
- action.yml / README.md: clarify that the output is also empty when caching
is skipped (e.g. the cache service is unavailable)
- dist: rebuild
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
brunoborges added a commit that referenced this pull request Jul 8, 2026
* feat: expose cache-primary-key output (#597)
Backport of the cache-primary-key output to the v5 release line.
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 (CommonJS)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply PR #1088 review suggestions to v5 backport
Port the review feedback from the main-line PR (#1088) into the v5 backport:
- src/cache.ts: use the STATE_CACHE_PRIMARY_KEY constant for the output name
instead of a duplicated string literal
- action.yml / README.md: clarify that the output is also empty when caching
is skipped (e.g. the cache service is unavailable)
- dist: rebuild
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@brunoborges

Copy link
Copy Markdown
ContributorAuthor

@copilot rebase with main, rebuild the project and push the updated dist folder to this PR

CopilotAI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@copilot rebase with main, rebuild the project and push the updated dist folder to this PR

Done in c9cdf7a.

I fetched latest main and rebased the branch (it was already up to date), rebuilt the project with npm run build, and pushed the updated dist artifacts to this PR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@brunoborges
brunoborges merged commit f848fd1 into mainJul 9, 2026
406 checks passed
@brunoborges
brunoborges deleted the brunoborges-psychic-meme branch July 9, 2026 15:19
Sign up for freeto 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.

Cache integration between actions/setup-java and actions/cache / actions/cache/restore

3 participants

@brunoborges