From 47c8ef5b55aaffc8f4d9fe36a894179122461f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Mon, 4 Nov 2024 10:38:34 -0600 Subject: [PATCH] Provide default version based on latest tag in branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Pereira --- Makefile | 1 + version/version.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6ed3ce755a0..4391ff66346 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ NODES ?= 10 PACKAGES ?= api actor command types util version integration/helpers LC_ALL = "en_US.UTF-8" +CF_BUILD_VERSION ?= $$(git describe --tags --abbrev=0) CF_BUILD_SHA ?= $$(git rev-parse --short HEAD) CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d") LD_FLAGS_COMMON=-w -s \ diff --git a/version/version.go b/version/version.go index 47a77f878d5..4878c51b59a 100644 --- a/version/version.go +++ b/version/version.go @@ -1,6 +1,10 @@ package version -import "github.com/blang/semver/v4" +import ( + "strings" + + "github.com/blang/semver/v4" +) const DefaultVersion = "0.0.0-unknown-version" @@ -11,6 +15,8 @@ var ( ) func VersionString() string { + // Remove the "v" prefix from the binary in case it is present + binaryVersion = strings.TrimPrefix(binaryVersion, "v") versionString, err := semver.Make(binaryVersion) if err != nil { versionString = semver.MustParse(DefaultVersion)