Repository navigation
fix: upload release assets while the release is still a draft - #10
Merged
Merged
Conversation
The log repository has immutable releases enabled, so GitHub rejects asset uploads to a release that is already published: curl: (22) The requested URL returned error: 422 The release was created already published and the assets were uploaded afterwards, so the run failed at the upload step while leaving a published release with zero assets behind. Uploads now happen in the only order that works: create as a draft, attach every asset, then publish last. The draft reuse path also matters for retries — a run that failed mid-upload leaves its draft behind, and re-running publishes that same draft instead of failing on a duplicate tag. An already published release is detected and left untouched rather than patched, because an immutable release cannot be modified and attempting to PATCH it would fail the job for no useful reason. While repairing the release that the old code left behind, deleting it turned out not to free its tag: GitHub rejects reuse with "tag_name was used by an immutable release". That is a permanent record, so it also affects this repository's history rather than the upload order alone. The publish request now checks the response body and reports that specific cause together with the draft id and asset count, instead of surfacing a bare curl exit code. Tests: script-checks.yml asserts the create call precedes the first upload, that both assets are uploaded, and that the publish PATCH is the final call. It also asserts a published release is left alone with no further API calls. The curl stub honours -o and -w so it exercises the same code path as CI. Signed-off-by: Oliver Lin <oliver@liuxiaozhen.dev>
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.
The log repository has immutable releases enabled, so GitHub rejects asset uploads to a release that is already published:
curl: (22) The requested URL returned error: 422
The release was created already published and the assets were uploaded afterwards, so the run failed at the upload step while leaving a published release with zero assets behind.
Uploads now happen in the only order that works: create as a draft, attach every asset, then publish last. The draft reuse path also matters for retries — a run that failed mid-upload leaves its draft behind, and re-running publishes that same draft instead of failing on a duplicate tag.
An already published release is detected and left untouched rather than patched, because an immutable release cannot be modified and attempting to PATCH it would fail the job for no useful reason.
While repairing the release that the old code left behind, deleting it turned out not to free its tag: GitHub rejects reuse with
"tag_name was used by an immutable release". That is a permanent record, so it also affects this repository's history rather than the upload order alone. The publish request now checks the response body and reports that specific cause together with the draft id and asset count, instead of surfacing a bare curl exit code.
Tests: script-checks.yml asserts the create call precedes the first upload, that both assets are uploaded, and that the publish PATCH is the final call. It also asserts a published release is left alone with no further API calls. The curl stub honours -o and -w so it exercises the same code path as CI.