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:
@@ -41,13 +41,17 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
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
|
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)
|
# Check if HEAD is at a tag (prepare-release may have just tagged it)
|
||||||
latest_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo '')"
|
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"
|
echo "detected_tag=$latest_tag" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user