Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cmd): injects version at build time
Couple of past released missed aligning harcoded `main.version` variable with the current tag. This results in confusing output of `gci --version`, where e.g. last release (tagged with `v0.13.5`) prints `0.13.4`. ```shell ❯ go install github.com/daixiang0/[email protected] ❯ gci --version gci version 0.13.4 ``` With this change, `main.Version` is calculated at build time and injected. Therefore it will always contain the tag that it was built from (or `devel` if it's built from untagged commit). ```shell ❯ make build ❯ ./dist/gci -v gci version devel ❯ git tag v0.13.13 ❯ make build BIN_OUTPUT: dist/gci ❯ ./dist/gci -v gci version 0.13.13 ``` With the upcoming `go1.24` release this information can obtaind from `runtime/debug.BuildInfo.Main.Version` [1], which will simplify the process even further. [1] golang/go#50603 (comment) Signed-off-by: bartoszmajsak <[email protected]>
- Loading branch information