Skip to content

Commit c3e9e59

Browse files
megahirtclaude
andcommitted
Fix version computation in GHA
The workflow was failing because tags weren't being fetched properly and the fallback logic for missing tags was broken. This fix: 1. Explicitly fetches tags with 'git fetch --tags --force' to ensure they're available for version computation 2. Improves fallback logic to handle missing tags by counting all commits instead of trying to use a non-existent v0.0.0 tag Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 160f5bd commit c3e9e59

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/build-test-installer-release.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
#working-directory: ${{ github.workspace }}
4141
shell: bash
4242
run: |
43+
# Explicitly fetch all tags to ensure they're available
44+
git fetch --tags --force
45+
4346
git describe --tags --match "v*" --abbrev=0 || echo "No existing tag found"
4447
# If this is a tag push and it starts with v, just use it and strip off the v
4548
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
@@ -51,13 +54,20 @@ jobs:
5154
fi
5255
5356
# Otherwise find the latest tag that starts with v
54-
LAST_TAG=$(git describe --tags --match "v*" --abbrev=0 2>/dev/null || echo "v0.0.0")
57+
LAST_TAG=$(git describe --tags --match "v*" --abbrev=0 2>/dev/null || echo "")
5558
5659
# Compute a build number based on number of commits since that tag
57-
COMMITS_SINCE_TAG=$(git rev-list ${LAST_TAG}..HEAD --count)
60+
if [[ -n "$LAST_TAG" ]]; then
61+
# Tag found, count commits since that tag
62+
COMMITS_SINCE_TAG=$(git rev-list ${LAST_TAG}..HEAD --count)
63+
# Final version: X.Y.Z.build
64+
Version="${LAST_TAG#v}.${COMMITS_SINCE_TAG}"
65+
else
66+
# No tag found, use 0.0.0 and count all commits
67+
COMMITS_SINCE_TAG=$(git rev-list HEAD --count)
68+
Version="0.0.0.${COMMITS_SINCE_TAG}"
69+
fi
5870
59-
# Final version: X.Y.Z (stripped off the v)
60-
Version="${LAST_TAG#v}.${COMMITS_SINCE_TAG}"
6171
echo "version=$Version" >> $GITHUB_OUTPUT
6272
echo "no tag push; using $Version"
6373

0 commit comments

Comments
 (0)