Closed ehearneRedHat closed 3 months ago
What are you thiking when you say non-releases? Could you give more info? If its what I'm thinking which is just when something is merged to main at any given time. If we automate adding the latest commit hash to version that can get very noisy and also would the latest commit not then be the commit of the gh action resulting in a new commit causing the action to be triggered again and rinse and repeat ?
What are you thiking when you say non-releases?
I am saying that for any changes on main that the version is reported as a commit hash.
If we automate adding the latest commit hash to version that can get very noisy
Agreed, it seems like a difficult task to do.
would the latest commit not then be the commit of the gh action resulting in a new commit causing the action to be triggered again and rinse and repeat ?
I am unsure as of now, but as I understand it, the commit hash is based on the file changes. It would depend on how the logic is implemented but if it was done as a recursive check, then that is correct.
After thinking about your questions, it might be best to close this comment and re-evaluate the issue at hand, and re-open if needed. Thanks for questioning the realisation of the issue. :)
@R-Lawton it seems like interest is ramping up for making this happen. It might be a good idea to research it further to see if it is possible. Therefore, I am going to re-open. :)
@R-Lawton I believe it is possible to do, but not as a GitHub Action. We could use git rev-parse HEAD
to get the hash of the latest commit, which would run the command as the user runs ./kuadrantctl version
and would therefore show the user where exactly their version of the code is coming from.
For example, we could implement this code in version/version.go
in order to show the user what version they are on.
func getCommitHash() (string, error) {
cmd := exec.Command("git", "rev-parse", "HEAD")
output, err := cmd.Output()
if err != nil {
return "v0.0.0", err
}
commitHash := strings.TrimSpace(string(output))
return commitHash, nil
}
version, err := getCommitHash()
if err != nil {
// implement code logic here to print v0.0.0 for systems without git installed
}
// implement code logic here to print commit hash for systems with git installed
Closing as resolved in #85 .
What:
For non-releases, on
main
branch, when there is a new change made, a GitHub action should pick this up and change the version inversion/version.go
to something along the lines ofdev - "commit hash"
so that when the user builds the binary and runs./kuadrantctl version
it reports: