fix(release): fetch tags before version resolution to support workflow_call from prepare-release
This commit is contained in:
@@ -46,14 +46,18 @@ jobs:
|
|||||||
requested_tag="$(printf '%s' "${REQUESTED_TAG:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
requested_tag="$(printf '%s' "${REQUESTED_TAG:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||||
|
|
||||||
if [[ -n "$requested_tag" ]]; then
|
if [[ -n "$requested_tag" ]]; then
|
||||||
# Explicit tag was provided
|
# Explicit tag was provided via input or workflow_call
|
||||||
normalized="${requested_tag#v}"
|
normalized="${requested_tag#v}"
|
||||||
tag="v${normalized}"
|
tag="v${normalized}"
|
||||||
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||||
# Running from a tag push
|
# Running from a tag push
|
||||||
tag="${GITHUB_REF#refs/tags/}"
|
tag="${GITHUB_REF#refs/tags/}"
|
||||||
normalized="${tag#v}"
|
normalized="${tag#v}"
|
||||||
elif tag_at_head="$(git describe --exact-match --tags HEAD 2>/dev/null)" && [[ -n "$tag_at_head" ]]; then
|
else
|
||||||
|
# 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
|
# Current HEAD is at a tag
|
||||||
tag="$tag_at_head"
|
tag="$tag_at_head"
|
||||||
normalized="${tag#v}"
|
normalized="${tag#v}"
|
||||||
@@ -62,6 +66,7 @@ jobs:
|
|||||||
echo "Provide a tag via the 'tag' input or ensure HEAD is at a tagged commit." >&2
|
echo "Provide a tag via the 'tag' input or ensure HEAD is at a tagged commit." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=${normalized}" >> "$GITHUB_OUTPUT"
|
echo "version=${normalized}" >> "$GITHUB_OUTPUT"
|
||||||
|
|||||||
Reference in New Issue
Block a user