Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add version info automatically if you build with go 1.18+ #417

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

natefinch
Copy link
Member

@natefinch natefinch commented Mar 25, 2022

The only reason we have an install script is to set build data. As of 1.18, we don't need that anymore. So, now the logic will be split, if you have 1.18, you can just do go install github.com/magefile/mage@latest and it'll Just Work™.

If you have go 1.17.x or earlier, you'll still need to run go run install.go to have the local mage binary report version info.

One slight suboptimalness (that's a word, I swear) of the 1.18 data is that it doesn't include tag info, only commit info. That's not very user-friendly, so I wrote code to get tag info from github... which means mage --version has to go out to the internet if it was build with 1.18. That stinks, but I think it's worth it if it means go install mostly just works.

This fixes #414

@natefinch
Copy link
Member Author

Evidently the version is in BuildInfo.Main.Version if you've used go install, but won't be there if you just build with go build from a locally cloned repo, so probably can just check that and if it exists, use it, otherwise do the network dance above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: use 1.18 build & source control info when available
1 participant