From f605ad47ca9800ce26fd91fd25c6c6f70f779886 Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Thu, 27 Jun 2024 19:52:35 +0200 Subject: [PATCH] Calculate version correctly when multiple tags are present When multiple tags are present on the same commit, the version was calculated incorrectly. E.g., when `latest`, `canary` and `v1.1.0` tags are present on the same commit, the command seems to sort alphabetically causing the version to always be set to `canary`. This behaviour breaks makes it impossible to release a finalized version, e.g., `v1.1.0`. Using matching results in the version being calculated from the latest released version. The version will look like this `v1.1.0-2-gf3862833` instead of `canary`. Signed-off-by: Kim Christensen --- releases/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releases/git.go b/releases/git.go index e19ec78..ef8ce04 100644 --- a/releases/git.go +++ b/releases/git.go @@ -81,7 +81,7 @@ func getCommit() string { // Get a description of the commit, e.g. v0.30.1 (latest) or v0.30.1-32-gfe72ff73 (canary) func getVersion() string { - version, _ := shx.OutputS("git", "describe", "--tags") + version, _ := shx.OutputS("git", "describe", "--tags", "--match=v*") if version != "" { return version }