From 31b4aa0d90393e6d93513284e453b7da7e92c62d Mon Sep 17 00:00:00 2001 From: Andrey Oblivantsev Date: Thu, 23 Jul 2026 15:31:56 +0100 Subject: [PATCH] fix(ci): retry tag fetch in Release workflow (#11) workflow_dispatch raced release-please: checkout of refs/tags/vX failed because the tag was not fetched yet. Clone main first, retry-fetch the tag, then check it out. --- .github/workflows/release.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61e370f..f77ace4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,10 +18,28 @@ jobs: name: GoReleaser runs-on: ubuntu-latest steps: + # Always clone default branch first. workflow_dispatch often races with + # release-please creating the tag; fetching refs/tags/X before it exists + # fails checkout. Retry fetch, then check out the tag. - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }} + + - name: Checkout release tag + env: + TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} + run: | + set -euo pipefail + echo "Releasing tag: $TAG" + for i in 1 2 3 4 5 6; do + if git fetch --force origin "refs/tags/${TAG}:refs/tags/${TAG}"; then + break + fi + echo "tag $TAG not visible yet (attempt $i); sleeping…" + sleep 10 + done + git rev-parse "refs/tags/${TAG}" + git checkout --force "refs/tags/${TAG}" - name: Set up Go uses: actions/setup-go@v5