Skip to content

Commit 38a995d

Browse files
[v7] Provide default version based on latest tag in branch (#3285)
* Provide default version based on latest tag in branch Signed-off-by: João Pereira <[email protected]>
1 parent 0edadab commit 38a995d

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

.github/workflows/tests-integration-reusable.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
uses: actions/checkout@v4
3838
with:
3939
ref: ${{inputs.gitRef}}
40+
fetch-depth: 0
4041

4142
- name: Checkout CF deployment tasks
4243
uses: actions/checkout@v4

.github/workflows/tests-integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
uses: actions/checkout@v4
5555
with:
5656
ref: ${{needs.get-sha.outputs.gitRef}}
57+
fetch-depth: 0
5758
- name: Set Up Go
5859
uses: actions/setup-go@v5
5960
with:

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ NODES ?= 10
33
PACKAGES ?= api actor command types util version integration/helpers
44
LC_ALL = "en_US.UTF-8"
55

6+
CF_BUILD_VERSION ?= $$(git describe --tags --abbrev=0)
67
CF_BUILD_SHA ?= $$(git rev-parse --short HEAD)
78
CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d")
89
LD_FLAGS_COMMON=-w -s \

version/version.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package version
22

3-
import "github.com/blang/semver/v4"
3+
import (
4+
"strings"
5+
6+
"github.com/blang/semver/v4"
7+
)
48

59
const DefaultVersion = "0.0.0-unknown-version"
610

@@ -11,6 +15,8 @@ var (
1115
)
1216

1317
func VersionString() string {
18+
// Remove the "v" prefix from the binary in case it is present
19+
binaryVersion = strings.TrimPrefix(binaryVersion, "v")
1420
versionString, err := semver.Make(binaryVersion)
1521
if err != nil {
1622
versionString = semver.MustParse(DefaultVersion)

0 commit comments

Comments
 (0)