Repository navigation
ci: upload release artifacts to a draft, then publish it - #6332
Conversation
GitHub's immutable-releases setting locks a release's assets when it is published, and every artifact here is uploaded after publication: the workflow fires on `release: [released]` and four jobs then add the `prqlc` binaries, the `.deb`s and the `.rpm`s. With the setting on, each of those uploads fails with `HTTP 422: Cannot upload assets to an immutable release`. So the release is now created as a draft, the artifacts are uploaded into the draft, and `publish-release` publishes it once they have all landed. The trigger moves from the release to the tag. Creating a draft emits no `release` event of any kind, so there is nothing to start the workflow while the release is still writable. The publish gate becomes `github.event_name == 'push' && github.ref_type == 'tag'`. Both halves carry weight: `nightly.yaml` calls this workflow and the `github` context inside a called workflow is the caller's push to `main`, so only the tag test separates a release from a smoke test; and excluding `workflow_dispatch` keeps today's property that a dispatch never publishes, which matters because a dispatch can be aimed at an existing tag by anyone with write access. The release notes now come from the `CHANGELOG.md` section for the tag, which is what was being pasted in by hand. A tag pushed without one fails `create-draft` rather than publishing a release with empty notes. `publish-winget` reads the release's assets, so it moves from `needs: build-prqlc` to `needs: publish-release`. The registry jobs are left where they are. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
prql-bot
left a comment
There was a problem hiding this comment.
The restructure holds together: the push && ref_type == 'tag' guard is applied consistently across every job, all four asset-uploading jobs sit in publish-release's needs:, and nothing else in .github/workflows/ keys off the release event. Two changes worth making, plus a doc inconsistency — all three inline.
The one that matters is create-draft's "already exists" fast path: it accepts a release that is already published and hands it to the four upload jobs. Under immutable releases every one of them then hits HTTP 422: Cannot upload assets to an immutable release — the failure this PR removes, reintroduced on the re-run path. It's reachable from "Re-run all jobs" on a run that already published, and from a release created through the Releases UI, which creates the tag and so fires push. development.md covers the draft-left-behind case but not this one.
The second is the reach of the changelog gate. create-draft reads as the release's precondition, but only the artifact path depends on it — publish-to-cargo, publish-python, publish-js, build-and-publish-snap, brew-dispatcher, publish-web, push-web-branch and push-devcontainer carry no needs: create-draft. So a tag pushed before the ## $version section exists still runs every registry publish up to its release-environment approval, and that approval is the only thing standing between a missing heading and a crates.io/PyPI/npm publish with no GitHub release to match — recoverable only by burning another patch version. A one-line needs: create-draft on each would make the gate match what the code comment claims for it; coupling the registry publishes to the GitHub-release path is a real design choice either way.
…issing (#1290) `GET /repos/{repo}/immutable-releases` requires repository admin, and the bot has write. So the `immutable-releases` check has never produced a verdict in a scheduled run — it reports `SKIP` whether the setting is on or off, and the nightly files a drift issue only for a `FAIL`. Here is last night's run in a consumer, from its session log: ``` Security checks: PASS branch-protection:main — Branch 'main' is protected (restrict-updates ruleset) PASS bot-permission — Bot 'worktrunk-bot' has 'write' permission PASS tag-protection — All tag creation and updates require admin access. SKIP immutable-releases — Could not read the immutable-releases setting. Repository admin access is required to verify it. ... ``` The bot's own summary from that run: "9 PASS, 1 SKIP (`immutable-releases`, needs repo admin to read). No FAIL, so no drift issue filed; the SKIP means it isn't an all-pass run either, so nothing was closed." That setting was in fact disabled. It had been since the repo installed tend, which predated the check, and nothing re-ran `tend check` with admin afterwards. The PUT is admin-only too, so the bot could not have repaired it either. A side effect of the permanent skip: the nightly's "every line PASS, close the drift issue" branch was unreachable in every consumer. Each published release carries GitHub's own `immutable` flag, which a write-scoped token can read. When the setting endpoint 404s, `check_immutable_releases` now reads the most recently published non-draft release instead and fails when it can still be rewritten. An admin's run is unchanged, and the module docstring records the rule that an admin-only read needs a bot-readable stand-in. Verified against live GitHub with the bot's own token: `max-sixty/tend` (setting on, newest release immutable) → PASS, `max-sixty/worktrunk` (was off) → FAIL, `max-sixty/leaf` (no releases) → SKIP. The flag is retrospective, so a repository that enables the setting with an older release already published fails this check until its next release, and turning the setting off goes unseen until the repository publishes again. The failure message, the security model and the `install-tend` guidance all say so. The alternative — failing only when an older release is immutable and a newer one is not — detects the setting being turned off but stays silent on the case that actually occurred, where it was never on. ## Finding the newest release is harder than it looks Two separate bugs, both caught in review, both now covered by tests. **The listing is not in publication order.** A release's `created_at` is its tag's commit date, not its publication time, and the endpoint documents no order. On a repository publishing from several trains a backport published later sorts below the newer version — `grafana/grafana` serves `v13.2.2` (published 12:21:32) ahead of `v13.0.9` (12:43:46), and `elastic/elasticsearch` does the same. **And it is paginated.** `gh api` serves 30 a page; this repository already has 36. Taking the maximum over page one repeats the same mistake, since a later publication can sit past the page boundary just as easily as past the first element. The call passes `--paginate`, and `--slurp` collects the pages — gh refuses it alongside `--jq`, so the draft filter and the maximum moved into Python. ## Immutability does not lock a release's body `PATCH /repos/{repo}/releases/{id}` with a new body succeeds on a release reading `immutable: true` — verified against this repository's own `0.2.10` release with the bot's write-scoped token, the exact actor the threat model names, and the body restored byte-for-byte afterwards. What the setting locks is the assets, the tag, and the draft/published state. `docs/security-model.md` (both the boundary headline and its paragraph), the shipped `install-tend` reference and SKILL.md, `README.md`, and `checks.py`'s docstrings and messages all claimed notes were covered; they now say assets and tags. ## Repository settings The setting is now enabled on `max-sixty/worktrunk`, `max-sixty/leaf`, `max-sixty/cargo-affected` and `numbagg/numbagg`. `PRQL/prql` is waiting on PRQL/prql#6332, which restructures its release workflow to upload assets to a draft — today it uploads to the already-published release across four jobs, which the setting refuses with `HTTP 422: Cannot upload assets to an immutable release`. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…he draft Two gaps from review. `create-draft` reused any existing release, including a published one. That is reachable by the old ritual — creating the release in the web UI creates the tag, which starts this workflow, which would then find a published release and fail four separate upload jobs with the 422 this change exists to avoid. It now reads `isDraft`: a draft is reused, a published release stops the run with a message saying to delete it and re-push the tag. `create-draft` also decides whether the changelog section exists, and nothing downstream waited on that. A tag pushed without one would have failed the GitHub release while crates.io, PyPI and npm published anyway — irreversibly, and with no release to accompany them. Every publishing job now needs `create-draft`. They wait on that gate rather than on `publish-release`, so a failed `prqlc` build still blocks the release without blocking the registries, as it does today. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The releasing steps asked for "the new version and date" two sentences before requiring a heading of exactly `## $version`, which would have had a maintainer drop the date. The workflow's `awk` matches `## <tag>` followed by a non-`[0-9.]` character, so the established `## 0.13.14 — 2026-07-24` form is what it expects. The pointer also named step 3, which is the tag push; the reading happens in the workflow. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
prql-bot
left a comment
There was a problem hiding this comment.
Both earlier points are addressed: an already-published release is now fatal, and every registry job waits on create-draft.
What's left is that neither of create-draft's error messages names a recovery that works — inline. These are the annotations a maintainer reads mid-release with a tag already pushed, so following them costs a round of confusion at exactly the wrong moment, and the second one silently lands them back on the same failure.
Both error messages pointed at steps that change nothing. `gh release delete` leaves the tag in place unless `--cleanup-tag` is passed, so "re-push the tag" was a no-op — `Everything up-to-date`, and no run started. Re-running the existing run replays the same tag push, and the job then finds no release and creates the draft. The job checks out the tag, so the changelog is read at the tagged commit. Adding the section to `main` and re-running read the same file and failed identically; the tag has to move to the commit that has the section. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Moving a tag is an `update` against both all-tags rulesets, and the one covering deletion bypasses only org admins and admins — so the remedy was unactionable for a maintainer without admin. `create-draft` already reuses an existing draft, so making one by hand and re-running is the second route, and it needs no bypass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
GitHub's immutable-releases setting locks a release's assets and its tag when it is published. Every artifact here is uploaded after publication — the workflow fires on
release: [released], and four jobs then add theprqlcbinaries, the.debs and the.rpms — so with the setting enabled each of those uploads fails:This restructures the release so it works with the setting on: the release is created as a draft, the artifacts are uploaded into the draft, and a new
publish-releasejob publishes it once they have all landed.What changes
The trigger moves from the release to the tag. Creating a draft emits no
releaseevent of any kind, so there is nothing to start the workflow while the release is still writable.on: release: [released]becomeson: push: tags:.The publish gate becomes
github.event_name == 'push' && github.ref_type == 'tag'. Both halves carry weight.nightly.yamlcalls this workflow, and inside a called workflow thegithubcontext is the caller's — a push tomain— soevent_namealone cannot tell a release from a smoke test; the tag test is what separates them. And excludingworkflow_dispatchpreserves today's property that a dispatch never publishes, which matters because a dispatch can be aimed at an existing tag by anyone with write access.Release notes come from
CHANGELOG.md.create-draftreads the## $versionsection at the tagged commit, which is what was being pasted into the release description by hand. A tag pushed without a matching section fails the job rather than publishing a release with empty notes. This also retires the footnote about GitHub's markdown parser mangling the pasted text.publish-wingetmoves fromneeds: build-prqlctoneeds: publish-release, sincewinget-releaserreads the release's published assets. The registry jobs (publish-python,publish-js,publish-to-cargo,brew-dispatcher, snap, web, devcontainer) are left exactly where they are.The releasing section of
development.mdis updated: step 3 becomesgit tag $version && git push origin $version.How this was verified
The mechanics were tested end-to-end against real GitHub on a scratch repository with immutable releases enabled, not just read out of the docs:
softprops/action-gh-release@v3withtag_name+draft: true, and aneeds:-gated job published it. Final statedraft: false, immutable: true, every assetuploaded, download URLs returning 200.softpropsitself rewrites it to "GitHub only allows asset uploads before a release is published, so upload assets to a draft release before you publish it".published+released.append_body: truewith nobody:preserves the seed notes byte-for-byte, so the changelog text survives the uploads.CHANGELOG.md, including the prefix case —0.13.1does not match the0.13.14heading.Also checked in this repo: no other workflow triggers on the
releaseevent, so nothing downstream depends on that event still firing; andrelease.yamlis the only tag-triggered workflow, so the tag does not double-fire.actionlintand the rest ofpre-commitpass.Gates
create-draftis where the run stops if it should not proceed, and every publishing job waits on it:isDraft: a draft is reused so notes can still be written by hand beforehand, a published release stops the run with the remedy in the message.brew-dispatcher,build-and-publish-snap,publish-python,publish-js,publish-to-cargo,publish-web,push-web-branchandpush-devcontainerallneeds: create-draft, so a tag pushed without a section cannot publish to crates.io, PyPI or npm irreversibly while the GitHub release fails. They wait on that gate rather than onpublish-release, so a failedprqlcbuild still blocks the release without blocking the registries, exactly as today.What this cannot verify
The pipeline only fully proves itself on a real release. The parts that are structurally new and untested here are the failure path — if an upload job fails,
publish-releaseis skipped and an unpublished draft is left behind, whichcreate-draftthen reuses on a re-run — and the interaction with thereleaseenvironment's approval gates, which were not exercised on the scratch repository.Both of
create-draft's errors name a recovery that was checked rather than assumed.gh release deletekeeps the tag unless--cleanup-tagis passed, so the already-published case asks for a re-run of the existing run rather than another tag push, which would be a no-op. And the job checks out the tag, so the missing-changelog case asks for the tag to be moved to the commit that carries the section — or, since moving a tag is anupdateagainst both all-tags rulesets and the deletion one bypasses admins alone, for the draft to be made by hand and the run re-run, which needs no bypass.Immutable releases should be enabled on this repository only after this merges, not before.