From e8e1dc969578709353d4021e58e203f0d367aa29 Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Fri, 20 Mar 2026 21:24:52 +0000 Subject: [PATCH] fix: make prepare action resilient for reruns - Disable setup-go module cache path in prepare action's source-run mode to avoid invalid '..' cache-dependency-path patterns. - Make commit/tag step idempotent when release tag already exists locally or remotely. - Skip empty commit attempts when no release files changed while still allowing first-time tag creation. --- prepare/action.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/prepare/action.yml b/prepare/action.yml index 4c41e3f..787c4bf 100644 --- a/prepare/action.yml +++ b/prepare/action.yml @@ -109,8 +109,7 @@ runs: uses: actions/setup-go@v5 with: go-version: '1.26.1' - cache: true - cache-dependency-path: ${{ github.action_path }}/../go.sum + cache: false - name: Restore cached vociferate binary id: cache-vociferate @@ -192,11 +191,6 @@ runs: run: | set -euo pipefail - if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then - echo "Tag ${RELEASE_TAG} already exists" >&2 - exit 1 - fi - case "$GITHUB_SERVER_URL" in https://*) authed_remote="https://oauth2:${TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" @@ -214,11 +208,21 @@ runs: git config user.email "$GIT_USER_EMAIL" git remote set-url origin "$authed_remote" + if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1 || git ls-remote --exit-code --tags origin "refs/tags/${RELEASE_TAG}" >/dev/null 2>&1; then + echo "Tag ${RELEASE_TAG} already exists; skipping commit/tag/push." + exit 0 + fi + for f in $GIT_ADD_FILES; do git add "$f" done - git commit -m "release: prepare ${RELEASE_TAG}" + if git diff --cached --quiet; then + echo "No staged release file changes; tagging current HEAD as ${RELEASE_TAG}." + else + git commit -m "release: prepare ${RELEASE_TAG}" + fi + git tag "$RELEASE_TAG" git push origin HEAD git push origin "$RELEASE_TAG"