File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,23 @@ $ErrorActionPreference = 'Stop'
19
19
$versionH = $Args [0 ];
20
20
echo " Generating $versionH ..."
21
21
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
+ }
23
39
24
40
# We expect $describe to be of the form:
25
41
# VERSION_W.X.Y.Z-[number of commits ahead]-[commit hash]
You can’t perform that action at this time.
0 commit comments