Skip to content

Commit 0c828d4

Browse files
Build version fix (#9)
Fix the build version generation on new tags as git describe did not work as expected
1 parent 7ae488a commit 0c828d4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+'
79
pull_request:
810
branches:
911
- main
@@ -27,13 +29,16 @@ jobs:
2729
id: get_version
2830
shell: pwsh
2931
run: |
30-
# Set version
31-
$TAG = (git describe --tags --exact-match 2>$null) -or ""
32+
$TAG = if ($env:GITHUB_REF -like "refs/tags/v*") {
33+
$env:GITHUB_REF -replace 'refs/tags/v', ''
34+
} else {
35+
""
36+
}
3237
33-
if ($TAG -like "v*") {
34-
# Remove the 'v' prefix
35-
$VERSION = $TAG.Substring(1)
38+
if ($TAG -ne "") {
39+
$VERSION = $TAG
3640
} else {
41+
# Fallback to commit hash if no tag
3742
$COMMIT_HASH = git rev-parse --short HEAD
3843
$VERSION = "0.0.1-$COMMIT_HASH"
3944
}

0 commit comments

Comments
 (0)