fix(workflows): prioritize HEAD tag detection over global latest tag

When prepare-release tags HEAD with a new release version, do-release should
immediately detect that tag rather than finding the latest tag chronologically.

Changes:
- Modified detect-tag step to check if HEAD is exactly at a tag first
- Falls back to latest tag only if HEAD is not tagged
- Fixes issue where v1.0.2 was detected instead of v1.1.0 at HEAD

This ensures correct version detection in prepare-release → do-release workflow chain.
This commit is contained in:
Micheal Wilkinson
2026-03-21 15:58:25 +00:00
parent cb52dd909d
commit a6d57e4048

View File

@@ -41,13 +41,17 @@ jobs:
run: |
set -euo pipefail
# Fetch all tags from origin to ensure we have the latest
# Fetch all tags from origin first
git fetch origin --tags --force --quiet 2>/dev/null || true
# Try to find the most recent tag (in case it was just created by prepare-release)
latest_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo '')"
# Check if HEAD is at a tag (prepare-release may have just tagged it)
if head_tag="$(git describe --exact-match --tags HEAD 2>/dev/null)" && [[ -n "$head_tag" ]]; then
echo "detected_tag=$head_tag" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ -n "$latest_tag" ]]; then
# Fall back to finding the most recent tag
if latest_tag="$(git describe --tags --abbrev=0 2>/dev/null)" && [[ -n "$latest_tag" ]]; then
echo "detected_tag=$latest_tag" >> "$GITHUB_OUTPUT"
fi