-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Print a more useful string then 'devel' #519
Comments
I completely agree, but Go doesn't have a way to insert arbitrary code as part of its build process - and that is by design. Imagine if running Modules have introduced versioning to builds, but unfortunately, a local Until then, we have two alternatives, but they both kinda stink:
We do have a third option, which is to try to build the docker images in a way that includes good version information. This wouldn't fix regular |
If you run
or https://godoc.org/runtime/debug#ReadBuildInfo Docker build can also be updated to use |
So for the normal 'manual' build process (go build) I agree to wait until go sorts this upstream. |
@kaey that's not a good solution because it doesn't build what's actually in git. You're just building master. What if I want to build a tag, or a commit that hasn't been pushed to the remote? It could work for the Docker builds because they only happen to build master and tags which have been pushed out, but it's not a general solution. @oliv3r a pre-compilation step for Docker is the third method I described earlier. It could work, though it would still be very hacky. |
No. It builds whatever you specify after
You want to ship a binary without sources publicly available? Is it useful? For development you can still use a fallback to |
Right - by
You want the binaries to be consistent, ideally. Right now, the version is consistently static, and the build process is simple. Having two or three ways to build a binary is an option, but it's far from ideal. If we decide to do anything here, I think the most sensible would be to somehow force the Go build system to embed module version information into the build. If that requires internet access it's a bummer, but I don't think there's a way around it today. |
Having a way to set version string manually also gives you an ability to lie. You say it's tag Go takes away that ability from you. Want to patch? Make your fork publicly available and add replace directive to go.mod. |
Yeah, we agree on what we want. I just want to avoid forcing a build to do a network roundtrip if one wants the binary to have meaningful version information. Though perhaps that's the best we can have right now. |
@mvdan yeah, I was going with your pre-compilation step. Or maybe 'devsplaining' it ;) It's ugly, it's hacky, but for the docker container, would call it acceptable. What I was after I guess in my comment, if you have a preferred way to see it in a MR. I'd prefer to keep the --dirty flag, to truely mark the build, but the sed will always dirty the build, so it would have to be done in a version.go file that's not tracked. |
You need to have your deps vendored for that ¯_(ツ)_/¯ |
Lets start small however, if you are building your own thing, well then you aught to be smart enough to go to your source tree and find things. |
Sure, if anyone wants to give this a go or send a PR, that's welcome. |
Instead of a fixed string as version for development releases, this injects the latest git tag as version during build and thus allows to identify the binary later. Fixes mvdan#519.
Instead of a fixed string as version for development releases, this injects the latest git tag as version during build and thus allows to identify the binary later. Fixes #519.
This is fixed for the time being. All published binary and docker artifacts should be properly versioned from now on. The only gaps left at the moment are If we moved to the module build info, the first would start getting good version information, but not the second. So I don't think it's hugely important that we move to this fancier method today, as it's still not foolproof. golang/go#37475 seems to be getting traction now, so I think we might see some progress in the coming months. |
git describe --always --dirty
is pretty amazing to help identify (un)tagged versions. It would be nice if shfmt would do this 'compile' time during release mode. I'm not familiar enough with go, but in C we tend to have a ./configure time generated version.h, which get the content at compile time. Doing a sed on the string would also work, but would make the file 'dirty', so better not that.Especially when pulling the docker containers with the 'latest' tag, having identify-ability is quite useful, 'which version was used for this job, well version a.b.c-21-gdeadbeef is far more interesting then 'devel', even when the later statement is completely true :)
The text was updated successfully, but these errors were encountered: