fix(release): fetch tags before version resolution to support workflow_call from prepare-release
This commit is contained in:
@@ -46,21 +46,26 @@ jobs:
|
||||
requested_tag="$(printf '%s' "${REQUESTED_TAG:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
|
||||
if [[ -n "$requested_tag" ]]; then
|
||||
# Explicit tag was provided
|
||||
# Explicit tag was provided via input or workflow_call
|
||||
normalized="${requested_tag#v}"
|
||||
tag="v${normalized}"
|
||||
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||
# Running from a tag push
|
||||
tag="${GITHUB_REF#refs/tags/}"
|
||||
normalized="${tag#v}"
|
||||
elif tag_at_head="$(git describe --exact-match --tags HEAD 2>/dev/null)" && [[ -n "$tag_at_head" ]]; then
|
||||
# Current HEAD is at a tag
|
||||
tag="$tag_at_head"
|
||||
normalized="${tag#v}"
|
||||
else
|
||||
echo "A release tag is required when the workflow is not running from a tag push" >&2
|
||||
echo "Provide a tag via the 'tag' input or ensure HEAD is at a tagged commit." >&2
|
||||
exit 1
|
||||
# Try to find tags at HEAD (fetch latest first in case called from prepare-release)
|
||||
git fetch origin --tags --quiet 2>/dev/null || true
|
||||
|
||||
if tag_at_head="$(git describe --exact-match --tags HEAD 2>/dev/null)" && [[ -n "$tag_at_head" ]]; then
|
||||
# Current HEAD is at a tag
|
||||
tag="$tag_at_head"
|
||||
normalized="${tag#v}"
|
||||
else
|
||||
echo "A release tag is required when the workflow is not running from a tag push" >&2
|
||||
echo "Provide a tag via the 'tag' input or ensure HEAD is at a tagged commit." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
Reference in New Issue
Block a user