Skip to content

Add version-file input to read the Packer version from a .tool-versions file#177

Open
somaz94 wants to merge 1 commit into
hashicorp:mainfrom
somaz94:feat/version-file
Open

Add version-file input to read the Packer version from a .tool-versions file#177
somaz94 wants to merge 1 commit into
hashicorp:mainfrom
somaz94:feat/version-file

Conversation

@somaz94

@somaz94 somaz94 commented Jun 15, 2026

Copy link
Copy Markdown

This adds an optional version-file input so the Packer version can be read from a .tool-versions file (the format shared by asdf and mise), rather than hard-coding the version in the workflow. This lets a repository keep a single source of truth for its Packer version across local tooling and CI.

The input is fully opt-in and backwards compatible:

  • version stays the default path and is unchanged for existing users.
  • version-file points at a .tool-versions file; the action reads the line declared for the packer tool (e.g. packer 1.10.0).
  • If both are set, version takes precedence (with a warning), mirroring the behaviour of actions/setup-node's node-version / node-version-file.

action.yml now marks version as required: false (its latest default is retained), so either input may be supplied.

dist/index.js was regenerated with npm run build (tsc + ncc); the large diff is the bundle rebuild — the only functional source change is in src/index.ts.

Validation

  • npm run fmt — clean (prettier, no changes)
  • npm run build — succeeds (tsc + ncc), regenerated dist/index.js
  • Parsing logic unit-checked locally against .tool-versions content (multiple tools, comments, blank lines, missing-tool, multi-version-on-a-line) — all expected results
  • Added a version-file leg to the existing actions-self-test.yml self-test workflow, which exercises the rebuilt dist/ end-to-end (uses: ./ → resolve from .tool-versions → assert installed packer version)

Usage

- name: Setup `packer`
  uses: hashicorp/setup-packer@main
  with:
    version-file: .tool-versions

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8)

somaz94 added a commit to somaz94/somaz94 that referenced this pull request Jun 15, 2026
@somaz94 somaz94 marked this pull request as ready for review June 17, 2026 02:12
@somaz94 somaz94 requested a review from a team as a code owner June 17, 2026 02:12
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.

1 participant