Skip to content

Commit 9277e0f

Browse files
committed
🐛 fix(ci): main builds compute fresh CalVer and tag locally before Gradle
PR #4 broke the release workflow: Gradle's tag-driven version derivation expects an exact-match tag at HEAD, but on main there isn't one until the release job creates it. Result: git describe returned the post-tag dev format (e.g. v2026.05.08.30-1-g1be0321) and the release action used that string verbatim as the new tag and Release name. Fix: split the Compute version step. On refs/heads/main, compute a fresh CalVer from date + GITHUB_RUN_NUMBER and `git tag` HEAD locally so Gradle's git-describe finds an exact match. The release job then pushes this tag when creating the GitHub Release. PR / feature-branch builds keep using `git describe` for artifact-naming purposes. The bad tag/release v2026.05.08.30-1-g1be0321 has been deleted.
1 parent aace637 commit 9277e0f

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

.github/workflows/android-ci.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,23 @@ jobs:
5555
- id: version
5656
name: Compute version
5757
run: |
58-
# Match what app/build.gradle.kts derives from the same checkout.
59-
# Tags are pulled by checkout's fetch-tags: true; verify here.
60-
if ! git describe --tags --match 'v*' --abbrev=0 >/dev/null 2>&1; then
61-
echo "::error::No matching v* tag in history. Build will fail."
62-
git tag -l 'v*' | head
63-
exit 1
58+
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
59+
# On main: bump CalVer (date + CI run number) and tag the HEAD
60+
# locally so Gradle's git-describe finds an exact-match tag.
61+
# The release job pushes this tag when it creates the Release.
62+
BUILD_DATE=$(date -u +%Y-%m-%d)
63+
VERSION="${BUILD_DATE//-/.}.${GITHUB_RUN_NUMBER}"
64+
git tag "v$VERSION"
65+
else
66+
# On PRs / feature branches: derive from existing tag history.
67+
# Post-tag dev format is fine for non-release artifact names.
68+
if ! git describe --tags --match 'v*' --abbrev=0 >/dev/null 2>&1; then
69+
echo "::error::No matching v* tag in history. Build will fail."
70+
git tag -l 'v*' | head
71+
exit 1
72+
fi
73+
VERSION=$(git describe --tags --match 'v*' --always | sed 's/^v//')
6474
fi
65-
VERSION=$(git describe --tags --match 'v*' --always | sed 's/^v//')
6675
echo "VERSION_NAME=$VERSION" >> "$GITHUB_ENV"
6776
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
6877
echo "Building version $VERSION"

0 commit comments

Comments
 (0)