Skip to content

Default the Go CLI version to the tag without its leading v - #68

Merged
Ilyes512 merged 2 commits into
mainfrom
fix/go-cli-version-default
Sep 14, 2026
Merged

Ilyes512 merged 2 commits into
mainfrom
fix/go-cli-version-default

Conversation

@Ilyes512

Copy link
Copy Markdown
Member

Summary

  • version on build-go-cli.yml is now optional and defaults, on a tag push, to the tag with its leading v stripped.
  • merge-go-cli.yml needs no version at all — documented as the override it is, and dropped from the examples.
  • Docs examples updated; references bumped to 2.4.0.

Why

The documented way to supply the version was ${{ github.ref_name }}, which is v1.2.3. Every Go repo in the org also releases through GoReleaser, which strips the v when injecting the same ldflag — so following the example publishes an image reporting v1.2.3 while the binary cut from that very tag reports 1.2.3.

GitHub expressions can't strip a prefix, so each consumer had to add a job for it. specs-cli already has one. Resolving it here means the next consumer can't get it wrong by copying the example.

merge-go-cli.yml turned out to need nothing: metadata-action already sets org.opencontainers.image.version to the version it computed, so that input was overriding a correct default.

Edge cases

  • Explicitly passing version still overrides the default — for building a release from something other than its tag, or stamping a branch build.
  • On a non-tag trigger the default is empty, and the build arg is then omitted rather than passed empty, so the Dockerfile's own ARG …=dev fallback stands instead of the version becoming an empty string.

Versioning

Minor — 2.4.0. The input only gains a default; it was previously required, so no existing caller omits it and no existing caller's published output changes.

build-go-cli.yml required a version, and the documented way to supply it was
`${{ github.ref_name }}` — which is `v1.2.3`. Every Go repository in the org
also releases through GoReleaser, which strips the `v` when it injects the same
ldflag, so following the example publishes an image reporting `v1.2.3` while
the binary cut from that very tag reports `1.2.3`.

GitHub expressions have no way to strip a prefix, so every consumer had to add
a job for it. specs-cli already has one. Better to resolve it once here: the
input is now optional and defaults, on a tag push, to the tag with the `v`
removed. Explicitly passing a version still overrides it.

On any other trigger the default is empty and the build arg is omitted rather
than passed empty, so the Dockerfile's fallback stands instead of the version
being set to the empty string.

merge-go-cli.yml needed nothing: metadata-action already labels the image
org.opencontainers.image.version with the version it computed, so its `version`
input was overriding a correct default. Documented as the override it is, and
dropped from the examples.
@Ilyes512
Ilyes512 merged commit 114384e into main Sep 14, 2026
1 check passed
@Ilyes512
Ilyes512 deleted the fix/go-cli-version-default branch September 14, 2026 22:55
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