Skip to content

Commit 6d4845e

Browse files
RonnyPfannschmidtCursor AIclaude
committed
fix: only lock on published releases, keep updating drafts
The draft release is a staging area that gets continuously replaced as main evolves. Only a published (non-draft) release acts as a lock: - prepare-release: skips only when a published release exists for the version (meaning it is already on PyPI). Draft releases are freely overwritten by force-updating the release branch. - release-artifacts: creates or replaces the draft after every green test run. Skips only when a published release exists. To start a fresh release cycle after publishing, the next push to main with new fragments will compute a new version automatically. Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude Opus 4 <claude@anthropic.com>
1 parent 17786e1 commit 6d4845e

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

.github/workflows/prepare-release.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,24 @@ jobs:
3636
echo "branch=release-$VERSION" >> "$GITHUB_OUTPUT"
3737
echo "Computed version: $VERSION"
3838
39-
- name: Check for existing identical release branch
39+
- name: Check if release is already published or branch is up-to-date
4040
if: steps.version.outputs.version
4141
id: check
42+
env:
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4244
run: |
4345
VERSION="${{ steps.version.outputs.version }}"
4446
BRANCH="release-$VERSION"
47+
48+
# A published (non-draft) release means the version is locked in
49+
# and already on PyPI — do not touch the release branch.
50+
IS_DRAFT=$(gh release view "$VERSION" --json isDraft --jq '.isDraft' 2>/dev/null || echo "")
51+
if [ "$IS_DRAFT" = "false" ]; then
52+
echo "::notice::Release $VERSION is already published — nothing to do."
53+
echo "skip=true" >> "$GITHUB_OUTPUT"
54+
exit 0
55+
fi
56+
4557
# If the release branch already exists and was built from this
4658
# exact main commit, there is nothing to update.
4759
if git rev-parse --verify "origin/$BRANCH" >/dev/null 2>&1; then

.github/workflows/test.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,28 +189,27 @@ jobs:
189189
run: |
190190
VERSION="${{ steps.version.outputs.version }}"
191191
TAG="$VERSION"
192-
193-
# Generate release notes from the PR's CHANGELOG.rst changes.
194192
NOTES="Release $VERSION — built from \`${{ github.head_ref }}\` at ${{ github.event.pull_request.head.sha }}."
195193
196-
if gh release view "$TAG" >/dev/null 2>&1; then
197-
# Delete existing assets and re-upload.
194+
if gh release view "$TAG" --json isDraft --jq '.isDraft' 2>/dev/null | grep -q 'true'; then
195+
# Update existing draft: replace assets with freshly tested ones.
198196
gh release edit "$TAG" \
199197
--draft \
200198
--title "pluggy $VERSION" \
201199
--notes "$NOTES" \
202200
--target "${{ github.event.pull_request.head.sha }}"
203-
# Remove old assets.
204201
for asset in $(gh release view "$TAG" --json assets --jq '.assets[].name'); do
205202
gh release delete-asset "$TAG" "$asset" --yes
206203
done
204+
gh release upload "$TAG" dist/*
205+
elif gh release view "$TAG" >/dev/null 2>&1; then
206+
# A published (non-draft) release exists — version is locked.
207+
echo "::notice::Release $VERSION is already published — skipping."
207208
else
208-
gh release create "$TAG" \
209+
# No release exists yet — create a fresh draft.
210+
gh release create "$TAG" dist/* \
209211
--draft \
210212
--title "pluggy $VERSION" \
211213
--notes "$NOTES" \
212214
--target "${{ github.event.pull_request.head.sha }}"
213215
fi
214-
215-
# Upload the wheel and sdist as release assets.
216-
gh release upload "$TAG" dist/* --clobber

0 commit comments

Comments
 (0)