fix(cmd): injects version at build time #226
Open
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.
A couple of past releases missed aligning hardcoded
main.version
variablewith the current tag. This results in a confusing output of
gci --version
,where e.g. last release (tagged with
v0.13.5
) prints0.13.4
.With this change,
main.Version
is calculated at build time andinjected. Therefore it will always contain the tag it was
built from (or
devel
if it's built from untagged commit).With the upcoming
go1.24
release this information can be obtained fromruntime/debug.BuildInfo.Main.Version
[1].This will simplify the process even further.
[1] golang/go#50603 (comment)
Signed-off-by: bartoszmajsak [email protected]