Skip to content

Commit 4d00bcb

Browse files
committed
fix prod release pipeline
1 parent a346b7b commit 4d00bcb

1 file changed

Lines changed: 41 additions & 6 deletions

File tree

.github/workflows/desktop-release.yml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,31 @@ jobs:
9797
9898
echo "::notice::Building $CHANNEL v$VERSION against $API_URL"
9999
100+
- name: Refuse a duplicate release
101+
env:
102+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
GH_REPO: ${{ github.repository }}
104+
RELEASE_TAG: ${{ steps.compute.outputs.release-tag }}
105+
SOURCE_SHA: ${{ github.sha }}
106+
run: |
107+
set -euo pipefail
108+
# Prod's version comes from tauri.conf.json alone, so a second push to
109+
# `prod` without a version bump collides with the existing tag. Left
110+
# to the publish job that surfaces as a ~25-minute build that dies at
111+
# the last step; catch it here in seconds instead.
112+
#
113+
# Re-running the *same* commit is legitimate (e.g. a flaky publish),
114+
# so that case passes through — the publish job replaces the assets.
115+
EXISTING=$(gh release view "$RELEASE_TAG" --json targetCommitish -q .targetCommitish 2>/dev/null || true)
116+
if [ -z "$EXISTING" ]; then
117+
echo "No release exists for $RELEASE_TAG — proceeding."
118+
elif [ "$EXISTING" = "$SOURCE_SHA" ]; then
119+
echo "::notice::$RELEASE_TAG already exists for this commit; its assets will be replaced."
120+
else
121+
echo "::error::Release $RELEASE_TAG already exists, built from $EXISTING. Bump \"version\" in desktop/src-tauri/tauri.conf.json (or delete that release) before releasing again."
122+
exit 1
123+
fi
124+
100125
build:
101126
name: build (${{ matrix.platform }})
102127
needs: setup
@@ -392,9 +417,19 @@ jobs:
392417
EXTRA+=( --prerelease )
393418
fi
394419
395-
gh release create "$RELEASE_TAG" \
396-
--title "Clawbits $RELEASE_TAG" \
397-
--notes "$NOTES" \
398-
--target "$SOURCE_SHA" \
399-
"${EXTRA[@]}" \
400-
"${FILES[@]}"
420+
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
421+
# Only reachable when the release belongs to this same commit — the
422+
# setup job already rejected the forgot-to-bump case. Replace the
423+
# assets so a failed publish can be re-run without hand-deleting
424+
# the release.
425+
echo "::notice::$RELEASE_TAG exists for this commit — replacing its assets"
426+
gh release upload "$RELEASE_TAG" --clobber "${FILES[@]}"
427+
gh release edit "$RELEASE_TAG" --notes "$NOTES"
428+
else
429+
gh release create "$RELEASE_TAG" \
430+
--title "Clawbits $RELEASE_TAG" \
431+
--notes "$NOTES" \
432+
--target "$SOURCE_SHA" \
433+
"${EXTRA[@]}" \
434+
"${FILES[@]}"
435+
fi

0 commit comments

Comments
 (0)