From a6d57e40487f38643d61136f7c608c490cf0be16 Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Sat, 21 Mar 2026 15:58:25 +0000 Subject: [PATCH] fix(workflows): prioritize HEAD tag detection over global latest tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .gitea/workflows/do-release.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/do-release.yml b/.gitea/workflows/do-release.yml index 1ed46dd..091884d 100644 --- a/.gitea/workflows/do-release.yml +++ b/.gitea/workflows/do-release.yml @@ -41,13 +41,17 @@ jobs: run: | 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 - # Try to find the most recent tag (in case it was just created by prepare-release) - latest_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo '')" + # Check if HEAD is at a tag (prepare-release may have just tagged it) + 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" fi