From 9bf92ea0ca1ec7e547dbcf715d3d920d8e615870 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 1/2] 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 fca5f3607dd..8d1dd2ffa69 100644 --- a/Makefile +++ b/Makefile @@ -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 \ 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) From 5bd4a22965753c69099d7e7ccfd4823dc58adb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Tue, 5 Nov 2024 08:48:46 -0600 Subject: [PATCH 2/2] Fetch all tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Pereira --- .github/workflows/tests-integration-reusable.yml | 1 + .github/workflows/tests-integration.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/tests-integration-reusable.yml b/.github/workflows/tests-integration-reusable.yml index 4e1ee3cc356..518b866920f 100644 --- a/.github/workflows/tests-integration-reusable.yml +++ b/.github/workflows/tests-integration-reusable.yml @@ -50,6 +50,7 @@ jobs: uses: actions/checkout@v4 with: ref: ${{inputs.gitRef}} + fetch-depth: 0 - name: Checkout cf-acceptance-tests if: ${{ inputs.name == 'cats' }} diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 0a67252b7c5..a6023b6f7e3 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -99,6 +99,7 @@ jobs: if: ${{ inputs.run_unit_tests }} with: ref: ${{needs.get-sha.outputs.gitRef}} + fetch-depth: 0 - name: Set Up Go uses: actions/setup-go@v5 if: ${{ inputs.run_unit_tests }}