Report Go module version and checksum #462
Merged
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.
At present, when installing Task using
go install
, the version is reported asmaster
.As of Go 1.16,
go install
uses module-aware mode by default. As a result, the module version and checksum is stored within the binary.Version Reporting
This pull request improves version reporting by reading the module version and checksum from
BuildInfo
.The
main.version
symbol remains so that a commit hash can be written when building from source usingtask install
, although it should not be written to in other build scenarios (e.g. when creating release builds). As such, to suppress the-X main.version=...
linker argument, the default GoReleaserldflags
build configuration option is overridden so that only the-s -w
flags are used.GoReleaser Verifiable Builds
Published binaries do not currently contain module version and checksum information.
To address this, the verifiable builds option of GoReleaser has been enabled, meaning that Task will be obtained from the Go modules proxy before being built. As this option does not affect snapshot builds and instead requires that a tagged commit is built, I have been unable to verify that module details are added to the build information of binaries as expected. This is something which I would advise to test before merging to the main branch, otherwise release binaries might display
unknown
as their version.