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

Generate vfkit version from git tag #69

Merged
merged 4 commits into from
Jan 29, 2024
Merged

Conversation

cfergeau
Copy link
Collaborator

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.

Copy link
Member

@anjannath anjannath left a 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

@cfergeau
Copy link
Collaborator Author

I added the missing file. This also needs slightly more work when building in github actions, see containers/gvisor-tap-vsock@cf2df89

@anjannath
Copy link
Member

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

Copy link

openshift-ci bot commented Jan 22, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: anjannath
Once this PR has been reviewed and has the lgtm label, please ask for approval from cfergeau. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cfergeau cfergeau mentioned this pull request Jan 23, 2024
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>
Copy link

openshift-ci bot commented Jan 24, 2024

New changes are detected. LGTM label has been removed.

@cfergeau cfergeau force-pushed the version branch 2 times, most recently from 060f6f7 to 8e2bba5 Compare January 24, 2024 11:51
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>
@cfergeau
Copy link
Collaborator Author

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

I've now adjusted the gh actions workflows to have proper release information on tag pushes and on git builds.

@praveenkumar
Copy link
Member

/lgtm
/approve

@praveenkumar praveenkumar merged commit 452c2e0 into crc-org:main Jan 29, 2024
4 of 5 checks passed
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.

3 participants