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
feature idea: detect git short version hash during build and embed into binary #332
Comments
Thanks for raising this feature request @sneak. I think it's a good idea. Two potential solutions:
I'm leaning towards 1. since it's more automatic for the developer. I think 2. would need to be possible too though, at least passing in raw flags into Go. |
Hey @matthewmueller I wouldn't mind knocking this out. 1 should be more than simple enough. However, do you have any input for tackling 2? It's been a minute since I've looked at the bud codebase, so I gave it a cursory glance and noticed |
In my apps I usually do something like:
Then at build time (in my Makefile) I do this:
This embeds the version string into the app so that I can access it, which is useful for me because then in production I can access this value and put it in my footers and error messages so that I know precisely which commit is running.
It would be cool if
bud build
could detect if it's building out of a git repo, and embed the git shorthash into the built binary in this way. It seems that you could skip theldflags
part and simply "hardcode" the git shorthash into the main.go via the main.gotext template at build filesystem generation time.Anyway, just an idea, and I'm happy to take a crack at making a patch for this when I have some time, I just wanted to write it down while it's in my head.
The text was updated successfully, but these errors were encountered: