diff --git a/.gitea/workflows/do-release.yml b/.gitea/workflows/do-release.yml index be01cfe..69f07a0 100644 --- a/.gitea/workflows/do-release.yml +++ b/.gitea/workflows/do-release.yml @@ -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"