Default the Go CLI version to the tag without its leading v - #68
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
versiononbuild-go-cli.ymlis now optional and defaults, on a tag push, to the tag with its leadingvstripped.merge-go-cli.ymlneeds noversionat all — documented as the override it is, and dropped from the examples.2.4.0.Why
The documented way to supply the version was
${{ github.ref_name }}, which isv1.2.3. Every Go repo in the org also releases through GoReleaser, which strips thevwhen injecting the same ldflag — so following the example publishes an image reportingv1.2.3while the binary cut from that very tag reports1.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.ymlturned out to need nothing:metadata-actionalready setsorg.opencontainers.image.versionto the version it computed, so that input was overriding a correct default.Edge cases
versionstill overrides the default — for building a release from something other than its tag, or stamping a branch build.ARG …=devfallback 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.