fix: make prepare action resilient for reruns
Some checks failed
Push Validation / validate (push) Has been cancelled
Some checks failed
Push Validation / validate (push) Has been cancelled
- 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.
This commit is contained in:
@@ -109,8 +109,7 @@ runs:
|
|||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.26.1'
|
go-version: '1.26.1'
|
||||||
cache: true
|
cache: false
|
||||||
cache-dependency-path: ${{ github.action_path }}/../go.sum
|
|
||||||
|
|
||||||
- name: Restore cached vociferate binary
|
- name: Restore cached vociferate binary
|
||||||
id: cache-vociferate
|
id: cache-vociferate
|
||||||
@@ -192,11 +191,6 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
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
|
case "$GITHUB_SERVER_URL" in
|
||||||
https://*)
|
https://*)
|
||||||
authed_remote="https://oauth2:${TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
|
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 config user.email "$GIT_USER_EMAIL"
|
||||||
git remote set-url origin "$authed_remote"
|
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
|
for f in $GIT_ADD_FILES; do
|
||||||
git add "$f"
|
git add "$f"
|
||||||
done
|
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 tag "$RELEASE_TAG"
|
||||||
git push origin HEAD
|
git push origin HEAD
|
||||||
git push origin "$RELEASE_TAG"
|
git push origin "$RELEASE_TAG"
|
||||||
|
|||||||
Reference in New Issue
Block a user