From bd5fb4e90c69c5e5e0ff0bd20a42acd3c2d5c04d Mon Sep 17 00:00:00 2001 From: Kim Morrison <477956+kim-em@users.noreply.github.com> Date: Wed, 25 Mar 2026 12:10:54 +1100 Subject: [PATCH] fix: handle duplicate nightly tag in scheduled CI runs (#13114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes the scheduled nightly CI run failing with `fatal: tag 'nightly-YYYY-MM-DD' already exists` when a manual `workflow_dispatch` has already created today's nightly tag. The scheduled path now uses the same `-revK` revision logic that the manual re-release path already has: if `nightly-2026-03-24` exists, it creates `nightly-2026-03-24-rev1` (and so on). The existing guard against creating nightlies when HEAD has a non-nightly tag (e.g. a release tag) is preserved. 🤖 Prepared with Claude Code Co-authored-by: Claude Opus 4.6 (1M context) --- .github/workflows/ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e85faba7a..63b1338129 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,9 +76,20 @@ jobs: fi echo "nightly=$LEAN_VERSION_STRING" >> "$GITHUB_OUTPUT" else - # Scheduled: do nothing if commit already has a different tag + # Scheduled: do nothing if commit already has a different tag (e.g. a release tag) LEAN_VERSION_STRING="nightly-$(date -u +%F)" - if [[ "$(git name-rev --name-only --tags --no-undefined HEAD 2> /dev/null || echo "$LEAN_VERSION_STRING")" == "$LEAN_VERSION_STRING" ]]; then + HEAD_TAG="$(git name-rev --name-only --tags --no-undefined HEAD 2> /dev/null || true)" + if [[ -n "$HEAD_TAG" && "$HEAD_TAG" != "$LEAN_VERSION_STRING" ]]; then + echo "HEAD already tagged as ${HEAD_TAG}, skipping nightly" + elif git rev-parse "refs/tags/${LEAN_VERSION_STRING}" >/dev/null 2>&1; then + # Today's nightly already exists (e.g. from a manual release), create a revision + REV=1 + while git rev-parse "refs/tags/${LEAN_VERSION_STRING}-rev${REV}" >/dev/null 2>&1; do + REV=$((REV + 1)) + done + LEAN_VERSION_STRING="${LEAN_VERSION_STRING}-rev${REV}" + echo "nightly=$LEAN_VERSION_STRING" >> "$GITHUB_OUTPUT" + else echo "nightly=$LEAN_VERSION_STRING" >> "$GITHUB_OUTPUT" fi fi