From 489d7dbc8ff926223d1032ffa56aecd33edb760d Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 11 Jun 2024 12:33:23 -0400 Subject: [PATCH] Use github_ref_name if available --- cmd/common.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/common.go b/cmd/common.go index 86b9a5c..d509bfd 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -180,10 +180,16 @@ func (cmd *BaseCommand) EvalCurrentAndNextVersion() { } if cmd.useCurrentTag { - tag := cmd.runCommandWithOutput("get current git tag", "git", "describe", "--tags") - v, err := version.NewVersion(tag[0]) + tag := "" + if strings.EqualFold("true", os.Getenv("GITHUB_ACTIONS")) { + tag = os.Getenv("GITHUB_REF_NAME") + } else { + tags := cmd.runCommandWithOutput("get current git tag", "git", "describe", "--tags") + tag = tags[0] + } + v, err := version.NewVersion(tag) if err != nil { - panic(fmt.Errorf("unable to parse tag %s", tag[0])) + panic(fmt.Errorf("unable to parse tag %s", tag)) } cmd.CurrentVersion = v