Repository navigation
feat(release): attach assets before publication - #59
Merged
Merged
Conversation
Troublor
reviewed
Nov 20, 2026
Reject blank asset lists before creating a tag. Test both empty and whitespace-only lines.
5 of 6 tasks
flyq
approved these changes
Nov 20, 2026
The stranded-draft cleanup added for `asset_files` listed every draft at the release tag and deleted it, with no check of where it came from and no log annotation. A maintainer's unpublished notes at that tag were destroyed irreversibly and silently, and the loop runs on a fresh publish too, so a draft written ahead of the release was in range. Deleting a Release cannot be undone, so the cleanup now has to prove the draft is its own. - New optional `release_author` input, defaulting to the app identity the pipeline publishes as. A draft at the tag is replaced only when `gh` created it as that identity; any other draft, or one with no author, is refused with an error and left untouched. Empty refuses every pre-existing draft. - Each deletion is announced with a warning, so it is never silent. - A 404 on the per-ID recheck is the outcome the loop wants, not a failure: continue instead of letting `set -e` abort the step after the tag is pushed. Any other read failure surfaces `gh`'s output and a named error, matching how the `releases/latest` read and `release-route`'s `has_tag` already behave. - The guard's asset checks and `SHA256SUMS` only run for a publish that will create the Release, so a retry of a finished run stays the documented no-op whatever `asset_files` names, instead of demanding the files still be on disk. Tests: a foreign draft and an unattributable draft are both refused with nothing deleted and the draft intact; its own draft is deleted, announced and published; a draft that 404s between the listing and the read does not stop the publish, while a 500 refuses with a named error; a finished publish stays a no-op with `asset_files` naming paths that do not exist. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Troublor
approved these changes
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Releases in several org repositories are now immutable once published: mega-evm, stateless-validator, mega-kona, mega-reth and mega-optimism.
release-assetsruns fromon-release.ymlonrelease: published, which is after the Release has become immutable, so it can no longer attach anything. Two releases hit this and shipped without their binaries:Both failed with
HTTP 422: Cannot upload assets to an immutable release.This PR lets a caller attach files at publication time instead. A caller that does not use the new input behaves exactly as before.
release-publishasset_files: newline-separated paths, empty by default.asset_filesnames. Each path must be an existing regular file, not a symlink. Basenames must be unique,SHA256SUMSis reserved, and#is refused becauseghreads it as a label separator. Blank and whitespace-only lines are skipped. Anasset_filesthat names no usable path fails, so it can never fall back to an assetless publish. The guard also writes aSHA256SUMSover the files.SHA256SUMSto the existinggh release create.ghcreates a draft, uploads the files and then publishes, so the assets are in place before the Release becomes immutable.release_authorinput (defaultmega-gutenberg[bot], the identity the pipeline publishes as) must match the draft's author. Any other draft at the tag, or one with no author, is refused with an error and left untouched — deleting a Release cannot be undone, so someone's unpublished notes are never destroyed. Each deletion is announced with a warning. Each draft is re-read by ID right before deletion, so a published Release is never deleted; a 404 on that read is the outcome the loop wants and is skipped, while any other read failure refuses with a named error.gh release createfails, the fallback accepts only a published Release. Withasset_files, that Release must also carry every expected asset andSHA256SUMS, all uploaded.asset_files, thegh release createarguments are unchanged.Drafts no longer count as an existing Release. This applies to:
release-publish;has_published_releaseinrelease-route;release-settle.Docs and templates
release-assetsnow says it cannot attach to an immutable Release, and points toasset_files.workflow-templates/on-release.ymldrops the post-publish attach example.workflow-templates/release-settle.ymlshows how to opt in.RELEASE.mdanddocs/RELEASING.mddescribe attaching assets at publication.Opting in. A caller adds a credential-free build job to its
release-settle.ymland hands the files topublish:No caller changes are needed. mega-evm will opt in in a follow-up PR; stateless-validator can do the same.
Testing
actions-test.ymlNew cases:
asset_files, the create arguments are exactly as before;asset_files, the files and a correctSHA256SUMSare passed;asset_fileswith only blank or whitespace-only lines fails before the tag step;Local run. These jobs run only on GitHub, so their
run:steps were executed locally with a harness, a fakeghand local Git remotes:release-tools(84) and.github/scripts(86) unit tests pass;action_docs.py --checkandapp_token_lint.pypass;actionlintreports nothing beyond the one existing SC2001 style note inactions-test.yml.This PR's CI runs the suite on GitHub.
Live rehearsal on GitHub
Setup. The rehearsal used a public sandbox repository with immutable releases enabled: RealiCZ/release-asset-rehearsal. Its releases and observer runs are the evidence below. For example, the v0.2.0
publishedrun shows the Release already immutable with all three assets uploaded.release: [created, published]recorded, at event time, the Release'sdraftandimmutableflags and its assets.Results:
asset_files. A fresh tag, plus a resume where the tag existed without a Releasecreatedand onepublishedevent, as today. (The first attempt hit a network TLS timeout; the step exited with an error and created nothing, and the re-run resumed cleanly.)publishedworkflow ran, the Release was already immutable, with both files andSHA256SUMSuploaded. The downloads matched the checksums.HTTP 422: Cannot upload assets to an immutable release, the failure this PR avoids.publishedrun saw the immutable Release with all three assets uploaded, and the downloads matched the checksums.asset_fileswith only blank lines, tag pushed firstasset_files is set but names no usable paths. No Release and no workflow run exist for v0.6.0.Review fixes (commit
f08e951)A review of the first two commits raised three things, all fixed in
f08e951:draft == true, with no log annotation, so a maintainer's unpublished notes at that tag were destroyed irreversibly and silently; the loop also runs on a fresh publish, so a draft written ahead of the release was in range. Now gated onrelease_authorand announced, as described above.gh apiexits 1 on 404 and the assignment is the failing command in awhilebody, soset -ekilled the step after the tag had been pushed, with no::error::annotation — even though a 404 means the draft is already gone, which is what the loop wants. It now continues on 404 and surfacesgh's output with a named error otherwise, matching thereleases/latestread andrelease-route'shas_tag.asset_filesblock sat above the already-published early exit, so a retry demanded the files still be on disk and failed where the README promises exit 0 with a notice. It is now conditioned on$publishedlike the order check and the dispatch changelog check.New cases in
actions-test.yml: a foreign draft and an unattributable draft are both refused with nothing deleted and the draft intact; its own draft is deleted, announced and published; a draft that 404s between the listing and the read does not stop the publish, while a 500 refuses with a named error; a finished publish stays a no-op withasset_filesnaming paths that do not exist. The fakeghgained author fields and a configurable per-ID 404/500.One review item is left open rather than fixed: GitHub's REST docs say it "renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods", without saying what the substitution is.
SHA256SUMS, the asset-name list and the uniqueness check all key on the local basename, and the test fixture isdist/my tool. If a space is renamed, the manifest no longer matches the published asset names and cannot be corrected, because it now lands behind the immutability boundary. Settling this needs one upload to a throwaway release to read back.assets[].name; if it renames, the fix is to refuse non-[A-Za-z0-9._-]basenames in the guard and rename the fixture.Notes and known limits
release: published, with nocreated, because the Release starts as a draft. No workflow in the org listens forrelease: created(code search).release-publish, only mega-optimism has a draft: a v2.0.0 draft from 2025-11-10, whose tag also exists.release-v2.0.0or a dispatch for 2.0.0 would reach that check.RELEASE.md,docs/RELEASING.mdandrelease-publish/README.md. The edits here are small and additive; whichever PR lands second rebases.