Skip to content

Commit

Permalink
Provide default version based on latest tag in branch
Browse files Browse the repository at this point in the history
Signed-off-by: João Pereira <joao.pereira@broadcom.com>
  • Loading branch information
joaopapereira committed Nov 4, 2024
1 parent 2353f30 commit 47c8ef5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
8 changes: 7 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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)
Expand Down

0 comments on commit 47c8ef5

Please sign in to comment.