Skip to content

Commit 0815577

Browse files
committed
Use GitHub Actions environment to determine tag name
1 parent 692fd09 commit 0815577

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

endless/src/endless/GenerateVersion.ps1

+17-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,23 @@ $ErrorActionPreference = 'Stop'
1919
$versionH = $Args[0];
2020
echo "Generating $versionH..."
2121

22-
$describe = (git describe)
22+
# When running workflows for a tag, GitHub actions/checkout@v2 doesn't just
23+
# check out the tag. Instead it does the following:
24+
# - pulls the repo
25+
# - uses ref-parse to determine the commit object the tag points at
26+
# - re-fetches with 'git fetch ... origin +$COMMIT_ID:refs/tags/$TAG'
27+
# - checks out that tag
28+
# As a result it loses the signed tag, which means 'git describe' reports the
29+
# version as the previous tag, plus a bunch of commits. Really weird.
30+
#
31+
# So we can't use 'git describe' and expect to get a bare tag back when we're
32+
# building that tag. Happily, we can just get the tag name from the GitHub
33+
# Actions environment and use that directly.
34+
if (($env:GITHUB_ACTIONS -eq "true") -and ($env:GITHUB_REF_TYPE -eq "tag")) {
35+
$describe = $env:GITHUB_REF_NAME
36+
} else {
37+
$describe = (git describe)
38+
}
2339

2440
# We expect $describe to be of the form:
2541
# VERSION_W.X.Y.Z-[number of commits ahead]-[commit hash]

0 commit comments

Comments
 (0)