Skip to content

feat(setup-pack): add pack-version-file input and verify download checksum - #428

Merged
edmorley merged 7 commits into
buildpacks:mainfrom
somaz94:feat/setup-pack-version-file-checksum
Jul 17, 2026
Merged

feat(setup-pack): add pack-version-file input and verify download checksum#428
edmorley merged 7 commits into
buildpacks:mainfrom
somaz94:feat/setup-pack-version-file-checksum

Conversation

@somaz94

@somaz94 somaz94 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

The setup-pack action only accepted an explicit pack-version, and it piped the downloaded archive straight into tar with no integrity check. This adds two things:

  1. A pack-version-file input that reads the version from a .tool-versions file (the pack entry) or a plain version file like .pack-version. Version resolution is now pack-versionpack-version-file → a pinned default, so an explicit pack-version always wins even when pack-version-file is also set — matching the setup-go go-version / go-version-file convention.
  2. Default-on SHA256 verification. Each pack release publishes a sibling <asset>.sha256, so the action now downloads the archive to a temp file, verifies it against that checksum, and only then extracts. If the checksum cannot be fetched it warns and proceeds, so mirror / air-gapped setups are not broken.

⚠️ Breaking change (major version bump)

To make the precedence above work, the pack-version input default was removed. setup-go can treat an empty go-version as "unset", but pack-version always carried a default, so a composite action could not tell "user asked for the default" from "defaulted" — which made pack-version-file unreachable whenever a default was present. The default is now a DEFAULT_PACK_VERSION in the step env: block, used only when neither input is set, and the update-pack-version workflow's sed is re-pointed at that line so the auto-bump keeps working.

Runtime behavior is unchanged for existing users (with nothing set, the pinned default is unchanged). But removing the input default is an API change, so this should land as a major version bump.

Validation

Done locally (the repo has no composite-action test harness, only the Go unit tests):

  • Version resolution covered: precedence (both set → inline wins / file-only / neither → default), .tool-versions with a pack entry (tab separated + trailing comment), plain version file (leading v, blank/comment lines, and inline trailing comment like 0.40.6 # pinned), and missing-file error.
  • Checksum path verified end to end against a real linux asset: a matching sum passes, a corrupted archive is rejected, and tar member extraction still yields the pack binary.
  • Re-pointed update-pack-version sed re-verified against the new DEFAULT_PACK_VERSION: env line.
  • shellcheck clean on both inline scripts.

somaz94 added a commit to somaz94/somaz94 that referenced this pull request Jun 19, 2026
@dmikusa

dmikusa commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

This sounds great! A couple of notes/questions:

  1. Question about precedence of the operators:

When set it takes precedence over pack-version.

This sounds backwards to me. As I read this, my understanding is that pack-version-file would take precedent over pack-version. Typically, the inline version takes precedent so pack-version would override pack-version-file. As an example, see the setup-go action docs:

If both the go-version and the go-version-file inputs are provided then the go-version input is used.

https://github.com/actions/setup-go/blob/main/docs/advanced-usage.md#using-the-go-version-file-input

  1. Question about sha256 checksum validation. I gather that you've added this for the pack-version-file case, did you also add sha256 validation for the pack-version path? As a user, I'd expect both paths to work the same way.

@somaz94

somaz94 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

On the checksum (2): it already covers both paths. The download and sha256 verification are in the shared "Install pack CLI" step that runs after version resolution, so the same archive is fetched and checked the same way whether the version came from pack-version or pack-version-file.

On precedence (1): you're right that inline-wins is the usual convention. I had the file win because pack-version carries a default (0.40.6, kept current by the update-pack-version workflow's sed on the default: line). Unlike setup-go's go-version, pack-version is never empty, so a composite action can't distinguish "user set 0.40.6" from "defaulted", and inline-always-wins would make pack-version-file unreachable.

If you're open to it I can match setup-go: drop the input default, resolve pack-version then pack-version-file then a fallback baked into the resolve step, and point the update-pack-version sed at that fallback line so the auto-bump still works. Or I keep file-as-override and just document it. Which do you prefer?

@somaz94
somaz94 marked this pull request as ready for review June 24, 2026 01:28
@somaz94
somaz94 requested review from a team and edmorley as code owners June 24, 2026 01:28

@jjbustamante jjbustamante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@somaz94 , @dmikusa . @edmorley

The checksum validation in this PR is valuable and backward-compatible on its own, so I'd suggest we land it and handle the pack-version vs pack-version-file precedence question as a follow-up? For reference, here's the trade-off we'd revisit:

Scenario PR as-is (file wins) setup-go semantics (inline wins)
User sets nothing default 0.40.6 needs a fallback baked into the resolve step
User sets pack-version only that version that version
User sets pack-version-file only file version file version
User sets both file wins (non-standard) inline wins (standard)
update-pack-version auto-bump keeps working (default line untouched) breaks unless the sed is re-pointed
Convention match surprising familiar

Based on that, I agree with @somaz94 approach to drop the default and add the fallback but we need to be careful with the automation for update-pack-version we have in place right now.

@somaz94

somaz94 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks both. I went with the inline-wins redesign you endorsed rather than splitting, since it's contained to this PR:

  • Dropped the pack-version input default and added a FALLBACK_PACK_VERSION constant in the resolve step. Precedence is now pack-versionpack-version-file → fallback, so an explicit pack-version wins even when pack-version-file is set — matching setup-go's go-version / go-version-file rule (@dmikusa's point 1).
  • Re-pointed the update-pack-version workflow's sed from the old default: line to the new FALLBACK_PACK_VERSION='…' line, so the auto-bump keeps working (@jjbustamante's automation concern). Verified the regex still matches and rewrites the fallback line.
  • On @dmikusa's point 2: checksum verification already covers both paths — it runs in the shared "Install pack CLI" step after version resolution, so it applies regardless of which input set the version.

Behavior stays backward compatible: with nothing set, the fallback equals the previous default. Validated locally — precedence (both / file-only / neither / leading-v / missing-file) and the re-pointed sed, plus shellcheck clean. Happy to split checksum out instead if you'd still prefer that.

@edmorley edmorley 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.

Thank you for the PR! Couple of comments but other than that looks good to go :-)

Comment thread setup-pack/action.yml Outdated
Comment thread setup-pack/action.yml Outdated
Comment thread setup-pack/action.yml Outdated
@edmorley edmorley added semver:major A change requiring a major version bump type:enhancement A general enhancement labels Jun 30, 2026
@edmorley

Copy link
Copy Markdown
Collaborator

Could you also rebase on main to resolve the merge conflicts?

@somaz94
somaz94 force-pushed the feat/setup-pack-version-file-checksum branch from 9c39ac9 to 89c8f6d Compare July 1, 2026 02:34
@somaz94

somaz94 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (the conflict was the update-pack-version auto-bump of the old default, now folded into FALLBACK_PACK_VERSION) and addressed all three review comments:

  • Parser inline-comment bug — plain version files now strip a trailing # ... comment before whitespace removal, so 0.40.6 # pinned resolves correctly.
  • Fallback location — moved into the step env: block as FALLBACK_PACK_VERSION, with the update-pack-version sed re-pointed accordingly.
  • PR description — updated to flag the default removal as a breaking change / major version bump.

shellcheck clean and version resolution re-validated locally. Thanks for the review!

@somaz94

somaz94 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Done — I've rebased onto the latest main and force-pushed. GitHub now shows the PR as mergeable with no conflicts. Thanks!

@edmorley edmorley 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.

Thank you for the changes!

A few unrelated changes snuck in since the last review (LLM?) - left some comments on those to revert in some cases (eg the "default" -> "fallback" change)

Comment thread setup-pack/action.yml Outdated
Comment thread .github/workflows/update-pack-version.yml Outdated
Comment thread setup-pack/action.yml Outdated
@somaz94

somaz94 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @edmorley — all six review comments are addressed in the pushed commits: inline trailing-comment stripping in the plain-file parser (0.40.6 # pinned no longer breaks the URL), the "could not determine a pack version" guard is now reachable, fallback reverted to default throughout, the fallback version moved into the step env: block, the PR description now calls out the breaking change / major bump, and the design-rationale prose is dropped from the input docs + README. PTAL / ready to resolve when you are.

@somaz94
somaz94 force-pushed the feat/setup-pack-version-file-checksum branch from 8e0b877 to d9a5d68 Compare July 9, 2026 03:28
somaz94 added 5 commits July 15, 2026 11:03
…cksum

Signed-off-by: somaz <genius5711@gmail.com>
…sion-file

Signed-off-by: somaz <genius5711@gmail.com>
Signed-off-by: somaz <genius5711@gmail.com>
Signed-off-by: somaz <genius5711@gmail.com>
Signed-off-by: somaz <genius5711@gmail.com>
@somaz94
somaz94 force-pushed the feat/setup-pack-version-file-checksum branch from d9a5d68 to 70387cc Compare July 15, 2026 02:04
@somaz94

somaz94 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main 👍 The earlier conflicts are gone — the only change on main since was the Go modules bump (#433), which doesn't touch the setup-pack action files, so it merges cleanly now.

The unrelated changes you flagged were all reverted in the earlier round:

  • fallbackdefault throughout (variable, comment, and the strings in update-pack-version.yml)
  • dropped the design-rationale prose from the input docs / README

Ready for another look whenever you have a moment — thanks!

edmorley added 2 commits July 17, 2026 12:17
Signed-off-by: Ed Morley <emorley@salesforce.com>
For some reason the GitHub merge conflict UI ignored my actual edits and committed the conflict markers.

Signed-off-by: Ed Morley <emorley@salesforce.com>

@edmorley edmorley 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.

Thank you for the PR! (And sorry for the delay in reviewing)

@edmorley
edmorley merged commit c1c7108 into buildpacks:main Jul 17, 2026
4 checks passed
@edmorley

edmorley commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

@edmorley

Copy link
Copy Markdown
Collaborator

Example of the new version working in CI (using the pinned default version):
https://github.com/heroku/buildpacks-python/actions/runs/29577246462/job/87874412638?pr=596#step:8:128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:major A change requiring a major version bump type:enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants