-
Notifications
You must be signed in to change notification settings - Fork 1
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
The binaries built by the release action include the commit hash in their version #38
Milestone
Comments
ejpcmac
added a commit
that referenced
this issue
Dec 5, 2024
The `build.rs` includes the commit hash by default in the version, but omits it when git-z is built exactly from a release tag. However, tags were not fetched in the release builds, making them include the commit hash even for releases. Refs: #38
Actually this is not solved 😭
|
ejpcmac
added a commit
that referenced
this issue
Feb 19, 2025
The build.rs includes the commit hash by default in the version, but omits it when git-z is built exactly from a release tag. This is done by comparing the current version with the output of `git describe`. However, `git describe` works only with annotated tags, but the GitHub action used for the release replaces the annotated tag with a lightweight tag to the same revision. Using `git describe --tags` should fix the issue. Refs: #38
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem description
If I run a binary downloaded from the release page and print its short version, I get the following:
Expected behaviour
In releases, the short version should not contain the Git revision.
Analysis
In the different build jobs of the release action, the Git repository is cloned using
actions/checkout@v4
without any parameter. By default, this only does a shallow clone, which does not include tags. Hence, thebuild.rs
is not able to check whether the build is made from a tag matching the version, and the revision is then included.Solution
Setfetch-tags: true
in the parameters foractions/checkout@v4
for thebuild-bin
,build-deb
andbuild-msi
jobs.^ This solution makes the fetch fail. Replacing it with
fetch-depth: 0
makes the build work again, but… does still include the hash.Second round of analysis
When fetching the repository with
fetch-depth: 0
on a tag, the action does the following:Is is then updating the tag so it directly points to the commit, instead of being an annotated tag. This only occurs if the action is triggered on a tag.
I have reproduced the last command locally, and then ran
git describe
. I am getting the following:Thanks to this comment, I have discovered that we can do
git describe --tags
:Second solution
Updating the
build.rs
to rungit describe --tags
instead ofgit describe
should fix the issue.The text was updated successfully, but these errors were encountered: