Skip to content

Commit

Permalink
[main] Provide default version based on latest tag in branch (cloudfo…
Browse files Browse the repository at this point in the history
…undry#3283)

* Provide default version based on latest tag in branch
* Full depth retrieval

Signed-off-by: João Pereira <[email protected]>

---------

Signed-off-by: João Pereira <[email protected]>
  • Loading branch information
joaopapereira authored Nov 5, 2024
1 parent a3d74bb commit dd2e812
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/tests-integration-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ jobs:
if: ${{ inputs.run_unit_tests || 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 || inputs.run_unit_tests == '' }}
Expand Down
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

0 comments on commit dd2e812

Please sign in to comment.