Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Provide default version based on latest tag in branch
Signed-off-by: João Pereira <[email protected]>
  • Loading branch information
joaopapereira committed Nov 5, 2024
commit 9bf92ea0ca1ec7e547dbcf715d3d920d8e615870
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FLAKE_ATTEMPTS ?=5
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