Skip to content

Commit 2da4e3f

Browse files
soloturnclaude
andauthored
ci(nightly): move the tag and edit the release in place, instead of delete+recreate (#726)
Retargeting the nightly tag (via the Git Data API - no checkout needed) is what actually moves the release, since a release points at whatever commit its tag currently resolves to, not a fixed SHA recorded on the release object. Editing the release in place then just refreshes title/notes; assets are swapped explicitly (delete what's there, upload this run's builds) since edit doesn't touch them and filenames embed the commit hash, so old ones are never overwritten by new uploads. Besides being simpler than delete+recreate, this means no new 'release published' notification goes out on every push to master: a bare tag move isn't a notified event, and editing an already-published release doesn't re-fire its original publish notification. (The prior delete+recreate approach relied on --prerelease being excluded from most watchers' default notification preferences instead.) Also drops the full commit SHA from the release title - a short hash (7 chars) is enough there; the full SHA stays in the notes and in every asset's own filename. Claude-Session: https://claude.ai/code/session_01V3dYofgD6GW7V21k6Mzfud Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent e5c73fc commit 2da4e3f

1 file changed

Lines changed: 37 additions & 20 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,46 @@ jobs:
6161
pattern: dist-*
6262
path: dist
6363
merge-multiple: true
64-
- name: Remove previous nightly release
64+
- name: Move the nightly tag to this commit
6565
env:
6666
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
# `gh release delete` fails if there's no prior `nightly` release (e.g. first
68-
# run ever) - that case is fine to skip. Any other failure means the old
69-
# release/tag may still be around, which would make the next step attach the
70-
# new release to the stale tag's commit (--target is ignored for existing
71-
# tags), so that must stop the job rather than being swallowed.
67+
# A release points at whatever commit its tag currently resolves to - it's not a fixed
68+
# SHA recorded on the release itself. So retargeting the tag is what actually moves the
69+
# release; editing the release object (next step) never touches that. This also means no
70+
# new "release published" notification goes out: unlike deleting+recreating the release,
71+
# a bare tag move isn't an event GitHub notifies watchers about, and editing an
72+
# already-published release in place doesn't re-fire the original publish notification.
7273
run: |
73-
if ! gh release delete nightly --yes --cleanup-tag --repo ${{ github.repository }}; then
74-
if gh release view nightly --repo ${{ github.repository }} >/dev/null 2>&1; then
75-
echo "::error::Failed to delete the existing nightly release/tag; refusing to publish onto it."
76-
exit 1
77-
fi
78-
echo "No existing nightly release to delete."
74+
if gh api "repos/${{ github.repository }}/git/refs/tags/nightly" >/dev/null 2>&1; then
75+
gh api --method PATCH "repos/${{ github.repository }}/git/refs/tags/nightly" \
76+
-f sha="${{ github.sha }}" -F force=true
77+
else
78+
gh api --method POST "repos/${{ github.repository }}/git/refs" \
79+
-f ref="refs/tags/nightly" -f sha="${{ github.sha }}"
7980
fi
80-
- name: Publish nightly release
81+
- name: Compute short commit hash
82+
id: short_sha
83+
run: echo "sha=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
84+
- name: Update or create the nightly release
8185
env:
8286
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83-
run: >
84-
gh release create nightly dist/*.zip
85-
--repo ${{ github.repository }}
86-
--target ${{ github.sha }}
87-
--title "Nightly build (${{ github.sha }})"
88-
--notes "Automated build from master@${{ github.sha }}. Not a stable release - replaced on every push to master. The launcher's own version display and each asset's filename both embed this same commit hash, so a bug report always maps back to an exact commit."
89-
--prerelease
87+
TITLE: "Nightly build (${{ steps.short_sha.outputs.sha }})"
88+
NOTES: "Automated build from master@${{ github.sha }}. Not a stable release - replaced on every push to master. The launcher's own version display and each asset's filename both embed the full commit hash, so a bug report always maps back to an exact commit."
89+
run: |
90+
if gh release view nightly --repo ${{ github.repository }} >/dev/null 2>&1; then
91+
# `edit` doesn't touch assets - the tag move above already repointed this release at
92+
# the right commit, so just refresh its title/notes, then swap the assets: delete
93+
# what's there (filenames embed the commit hash, so old ones are never overwritten by
94+
# this run's uploads) and upload this run's builds.
95+
gh release edit nightly --repo ${{ github.repository }} \
96+
--title "$TITLE" --notes "$NOTES" --prerelease
97+
gh release view nightly --repo ${{ github.repository }} --json assets --jq '.assets[].name' \
98+
| xargs -r -I{} gh release delete-asset nightly {} --repo ${{ github.repository }} --yes
99+
gh release upload nightly dist/*.zip --repo ${{ github.repository }}
100+
else
101+
# First run ever: nothing to edit yet. --target is ignored for an existing tag
102+
# (which the previous step already created pointing at the right commit), so this
103+
# still lands correctly.
104+
gh release create nightly dist/*.zip --repo ${{ github.repository }} \
105+
--title "$TITLE" --notes "$NOTES" --prerelease
106+
fi

0 commit comments

Comments
 (0)