Skip to content

fix: upload release assets while the release is still a draft - #10

Merged
Iamliuxiaozhen merged 1 commit into
mainfrom
fix/immutable-release-draft
Dec 1, 2026
Merged

Iamliuxiaozhen merged 1 commit into
mainfrom
fix/immutable-release-draft

Conversation

@Iamliuxiaozhen

Copy link
Copy Markdown
Member

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.

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>
@Iamliuxiaozhen
Iamliuxiaozhen merged commit 2578507 into main Dec 1, 2026
4 checks passed
@Iamliuxiaozhen
Iamliuxiaozhen deleted the fix/immutable-release-draft branch December 1, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant