From ea1b333da3fa3288165be66c5404bc6248901edf Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Sat, 21 Mar 2026 15:46:47 +0000 Subject: [PATCH] fix(release): fetch tags before version resolution to support workflow_call from prepare-release --- .gitea/workflows/do-release.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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"