-
Notifications
You must be signed in to change notification settings - Fork 26
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
Generate vfkit version from git tag #69
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing the .gitattributes
file
I added the missing file. This also needs slightly more work when building in github actions, see containers/gvisor-tap-vsock@cf2df89 |
so on github actions job we have to manually fetch the tags, thing to remember for when we add a automatic release job to this repo |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: anjannath The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This sets the version to `git describe --always --dirty` using the `-X github.com/crc-org/vfkit/pkg/cmdline.ModuleVersion` linker flag. The version will reflect more accurately what was built, as non-release build will show the git hash they were built from. Correct versioning when installing from tarballs, and through `go install` will be addressed in the next commits. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
This adds correct version information for `vfkit -version` when it's installed using: ``` go install github.com/crc-org/vfkit/cmd/vfkit ``` However, due to missing entitlements, a binary installed this way is unlikely to be able to start VMs. I'm keeping this codepath to use the same code in gvisor-tap-vsock and vfkit. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
When building from github tarballs, getting the version from `git describe` won't work. However, we can make use of $Format$ and .gitattributes as described in [1] to automatically substitute the correct version in a go variable when `git archive` is used. In particular, the correct version number will automatically be substituted when GitHub creates release tarballs. [1] https://icinga.com/blog/2022/05/25/embedding-git-commit-information-in-go-binaries/ Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
New changes are detected. LGTM label has been removed. |
060f6f7
to
8e2bba5
Compare
For `git describe` to work on non-tag pushes, we need the repo history/tags, a shallow clone with just the latest commit won't be enough. There's also a bug in actions/checkout for tag pushes, the tag is overridden with a non-tag, which breaks `git describe` for the tag. This commit adds a workaround for this. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
I've now adjusted the gh actions workflows to have proper release information on tag pushes and on git builds. |
/lgtm |
Currently the vfkit version must be manually set
before making a release, which is error-prone (this was the reason for the
0.1.1 release).
This PR generates it from git tags instead using git describe.
It also uses some git-archive magic to set the proper version
when a tarball is used for building vfkit.