Skip to content

Commit 5772b15

Browse files
authored
fix: release.yml tag introspection and add floating tag automation (#26)
Fixes two related bugs in release.yml: DTD#23: git describe --tags --abbrev=0 was used to find the latest tag for VERSION comparison. This returns the highest reachable tag (which can be a floating tag like v1.0 aliased to a commit), not the highest semver patch tag. When v1.0 was an annotated tag aliasing v1.8.2, the comparison broke entirely. Replaces with git for-each-ref --sort=-v:refname filtered to the semver pattern v[0-9]*.[0-9]*.[0-9]*. This returns clean semver output regardless of what floating tags exist. DTD#14: floating major.minor and major tags (v1.7, v1.0) had to be force-updated manually after each release. Adds an automated step that creates/updates vMAJOR.MINOR and vMAJOR lightweight tags pointing at the commit of the just-pushed patch tag. Both as lightweight tags (matches actions/checkout convention, avoids the alias bug that DTD#4's investigation surfaced). The floating tags are explicitly resolved through ^{commit} so the lightweight refs point at the underlying commit, not at the annotated patch tag's tag object. Closes #14, #23. Signed-off-by: 154358121+TMHSDigital@users.noreply.github.com Made-with: Cursor Signed-off-by: 154358121+TMHSDigital@users.noreply.github.com
1 parent 0e2fdee commit 5772b15

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ jobs:
5555
exit 1
5656
fi
5757
58-
LATEST_TAG="$(git describe --tags --abbrev=0 2>/dev/null || echo '')"
58+
# DTD#23: walk tag refs sorted by semver, filtered to the
59+
# vMAJOR.MINOR.PATCH pattern. Excludes floating tags like v1
60+
# and v1.7 (which lack the third segment) so the comparison
61+
# cannot be confused by an aliased or stale floating tag.
62+
# Glob is fnmatch: '[0-9]*' matches a digit followed by
63+
# anything, so vX.Y.Z and pre-releases (vX.Y.Z-rc1) match
64+
# while vX, vX.Y do not.
65+
LATEST_TAG="$(git for-each-ref --sort=-v:refname --format='%(refname:short)' 'refs/tags/v[0-9]*.[0-9]*.[0-9]*' | head -n1)"
5966
LATEST_VERSION="${LATEST_TAG#v}"
6067
6168
echo "VERSION file: $VERSION"
@@ -125,6 +132,32 @@ jobs:
125132
git tag -a "$TAG" -m "Release $TAG"
126133
git push origin "$TAG"
127134
135+
- name: Update floating major and major.minor tags
136+
env:
137+
TAG: ${{ needs.check-version.outputs.tag }}
138+
VERSION: ${{ needs.check-version.outputs.version }}
139+
run: |
140+
set -euo pipefail
141+
# DTD#14: maintain vMAJOR and vMAJOR.MINOR floating tags
142+
# automatically. Both patterns are in production: drift-check
143+
# consumers pin @v1.7 (MAJOR.MINOR train), release-doc-sync
144+
# consumers pin @v1 (MAJOR train).
145+
MAJOR="${VERSION%%.*}"
146+
REST="${VERSION#*.}"
147+
MINOR="${REST%%.*}"
148+
149+
# Resolve the patch tag to its commit. Required because a
150+
# bare 'git tag -f FLOAT ANNOTATED_TAG' would create a tag
151+
# pointing to the annotated tag object, not the commit -
152+
# the same alias-shape that broke DTD#4.
153+
PATCH_COMMIT="$(git rev-parse "${TAG}^{commit}")"
154+
155+
for FLOAT in "v${MAJOR}.${MINOR}" "v${MAJOR}"; do
156+
git tag -f "$FLOAT" "$PATCH_COMMIT"
157+
git push -f origin "$FLOAT"
158+
echo "Updated $FLOAT -> $PATCH_COMMIT"
159+
done
160+
128161
- name: Assemble release notes
129162
id: notes
130163
env:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8.3
1+
1.8.4

0 commit comments

Comments
 (0)