Closed limesten closed 11 months ago
I am trying out this branch and I am getting the following:
~/Documents/Personal/Go/test ❯ go-blueprint version Go Blueprint CLI version (devel)
Is this expected? I am unsure what i did
For the info.Main.Version to embed the version from the git tag it needs to be installed like:
go install github.com/melkeydev/go-blueprint@latest
(or with the specific version instead of latest)
If we install like that and then run go version -m go-blueprint
on the binary in the bin folder we get:
However, if we run go install
locally with the source code we will get (devel)
i'm a bit confused to why it's not working also at build i tested the build locally
Thoughts on these changes?
Added more comments
Added an additional fallback using git revision hash and date
Also changed to a less ambiguous output if no version info is available
Also for additional info about getting (devel) from local builds with debug.ReadBuildInfo() there are these related issues on the golang repo: https://github.com/golang/go/issues/29228 https://github.com/golang/go/issues/50603
@limesten I am still investigating this but it seems it still does not work
@limesten I am still investigating this but it seems it still does not work
I assume you are checking out the pr and then running go install. I've not found a good way to include the version info in this case.
It will work if:
1) you make a release with goreleaser (for example goreleaser build --single-target --skip-validate --clean
as a local test release)
(or manually enter a ldflag when running go build as @muandane did)
2) you install like this: go install github.com/melkeydev/go-blueprint@latest
or @v.0.4.1 etc
In this case the part after the @ is what gets added to the buildinfo so it will be accessible from the version command
The weird thing with 2) is that u cant't rly test it locally beforehand (as far as I can see at least) cuz this PR first needs to be included in a release so we can install it with go install github.com/melkeydev/go-blueprint@latest
😅 Hope that makes sense
@Melkeydev This is working. I created a test repo, pushed the tag, the build passed and the version was correct. LGTM
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
Problem/Feature
the command
go-blueprint version
works fine when downloading the pre-build binary from a release. However, if doinggo install github.com/melkeydev/go-blueprint@latest
it seems to result in an emptyGoBlueprintVersion
string.Description of Changes:
lost a few hairs on my head investigating this but:
getGoBlueprintVersion
If the version var has been set by goreleaser it will use that else we will useReadBuildInfo
from the runtime/debug package (which gets the version from git tags) also added a fallback which just prints version unknownChecklist