Repository navigation
Conversation
GitHub's immutable releases feature freezes a release's assets the moment the release is published, so the previous flow -- publish the release, then upload distribution assets in a follow-up request -- fails with "HTTP 422: Cannot upload assets to an immutable release" on any organization that has immutable releases enabled. When assets are provided, create the release as a draft, upload the assets while it is still mutable, and only then publish it via the new `publish_release` method. Releases without assets are still published directly, so that common path is unchanged. If an asset upload fails, the release is left as a draft rather than published without its assets. Closes python-semantic-release#1478 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Closing this after a closer look at the code paths. This change only reorders the In the default flow ( A proper native fix needs the release to stay a draft across both commands — |
What
The GitHub publish flow creates and publishes the release first, then uploads distribution assets in a separate request. GitHub's immutable releases freeze a release's assets the moment it is published, so that second upload now fails on any org with the feature enabled:
The release still gets created, but with no assets, and it can never be backfilled because it is immutable. Closes #1478.
The fix
create_releasenow creates the release as a draft when assets are present, uploads the assets while it is still mutable, then publishes it via a newpublish_releasemethod — the sequence immutable releases require.draft: False), as today. The extra publish round-trip only happens when assets are actually uploaded.IncompleteReleaseErroris raised, so nothing is published without its assets. The leftover draft is not auto-published or cleaned up on a re-run — it stays for the user to inspect, retry, or delete.Scoped to the GitHub HVCS; the other providers don't have this ordering.
Testing
test_create_release_with_assets_creates_draft_then_publishes— asserts create-as-draft, all assets uploaded, then a publish request.test_create_release_leaves_draft_when_asset_upload_fails— asserts the draft is never published on upload failure.test_github.pytests pass unmodified, confirming the no-assets path is untouched.pytest tests/unit/semantic_release/hvcs/test_github.py→ 203 passed.ruff checkandmypyclean.Related
This overlaps with #1193 (native draft-release support) — filed separately as a breakage on immutable-release orgs rather than a convenience feature. Heads-up: the
create_releaserewrite in #1436 keeps thedraft=False-then-upload order, so it would reintroduce this once merged.