Repository navigation
fix: publish releases after uploading assets - #452
Conversation
Assets of a published immutable release can't be added, replaced or deleted, so a re-run of the release workflow after its GitHub release was published failed (`gh release upload --clobber` gets HTTP 422), and a re-run never published a leftover draft. Create the GitHub release explicitly as a draft, upload the distributions and publish it last. Re-runs finish a draft of an earlier attempt. A published release gets no uploads: it must have all distributions, with the same digests, or the step fails and says what to do. The release lookup and asset check are in `scripts/release_assets.py` (as in cloud-registry), with tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A published release must now have exactly the distributions that the run built: assets without a digest count as changed, and assets that the run did not build are an error (as in cloud-registry). Reflow the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe release process now creates and uploads assets to a draft before publishing, safely completes drafts on reruns, and validates already-published releases by asset name and SHA-256 digest to avoid modifying immutable releases. A standard-library validation script, extensive tests, workflow Python setup, and contributor documentation support the new behavior. Sequence diagram for immutable release publishing and rerunssequenceDiagram
participant Workflow
participant Validator as release_assets.py
participant GitHub as GitHub Releases API
participant GH as gh CLI
Workflow->>GitHub: gh api --paginate --slurp releases
Workflow->>Validator: state TAG --releases FILE dist/*
Validator->>Validator: release_state(TAG, releases, assets)
alt No release
Validator-->>Workflow: state=none
Workflow->>GH: gh release create TAG --draft --generate-notes
Workflow->>GH: gh release upload TAG dist/* --clobber
Workflow->>GH: gh release edit TAG --draft=false
else Existing draft
Validator-->>Workflow: state=draft
Workflow->>GH: gh release upload TAG dist/* --clobber
Workflow->>GH: gh release edit TAG --draft=false
else Published release with matching assets
Validator->>Validator: check_published(TAG, release, assets)
Validator-->>Workflow: state=published
Workflow-->>Workflow: Exit without uploads
else Published release with missing or changed assets
Validator->>Validator: check_published(TAG, release, assets)
Validator-->>Workflow: error annotation, exit 1
end
Flow diagram for release state validationflowchart TD
A[Fetch all releases including drafts] --> B[release_state TAG releases assets]
B --> C{Release state}
C -->|none| D[Create draft release]
C -->|draft| E[Upload assets with clobber]
C -->|published| F[check_published]
C -->|Ambiguous drafts or draft plus published| G[Fail with error annotation]
F --> H{Names and SHA-256 digests match}
H -->|Yes| I[Skip uploads]
H -->|No| J[Fail and request a new patch version]
D --> E
E --> K[Publish draft]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #452 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 2872 2872
=========================================
Hits 2872 2872
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="scripts/release_assets.py" line_range="97" />
<code_context>
+ uploaded = {
+ asset.get("name"): asset.get("digest")
+ for asset in release.get("assets") or []
+ if asset.get("state") == "uploaded"
+ }
+ missing: list[str] = []
</code_context>
<issue_to_address>
**Unuploaded extras pass validation**
When a published release contains an unexpected asset whose state is not `uploaded`, `check_published` filters out assets in other states before checking for unexpected names, so the release passes validation and the workflow exits successfully despite the extra asset.
Check for unexpected asset names across all release assets before filtering by upload state.
Also at `scripts/release_assets.py:98`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and a workflow error could publish incorrect or incomplete assets under an immutable release tag, where reverting the workflow cannot replace or remove them; recovery may require issuing a new patch release. The impact is bounded to the affected release.
Blocking findings: scripts/release_assets.py:97
Look for unexpected assets of a published release among all of its assets, whatever their state, as unfinished uploads are visible too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The
github-releasejob of the release workflow is now safe with immutable releases (enabled for this repository) and re-runs. The same fix is in elixir-cloud-aai/cloud-registry#219 and elixir-cloud-aai/protes#287.gh release create --draft --generate-notes), uploads the distributions (gh release upload --clobber, which works on drafts), and publishes it last (gh release edit --draft=false).scripts/release_assets.py(the same as cloud-registry's, with tests) checks that the release has exactly the distributions that the run built, with the same SHA-256 digests (the API'sdigestfield). Otherwise the step fails with an::error::that says what to do (a new patch version).release-chart.ymlis not affected: it pushes the chart to GHCR and creates no GitHub release.Evidence for the old normal path (gh v2.102.0 on
ubuntu-latest):gh release create TAG files…already creates a draft, uploads and then publishes (draftWhileUploadinginpkg/cmd/release/create/create.go). The broken part was the re-run path, which rangh release upload --clobberon a published release. That fails on immutable releases with HTTP 422, as it did for cloud-registry v0.3.0.Verification
pytest tests/test_release_assets.py: 24 passed.tests/test_citation.pyalso passes.mypy(whole configured scope): no issues.pre-commit runon the changed files: passed (ruff, actionlint, semgrep, etc.).run:script from the workflow underbash -eo pipefailwith a stubgh, for each state:::error::, exit 1;::error::, exit 1.Declined review findings
--lateston publish: publishing throughgh release editsends nomake_latest, exactly like the oldgh release create(GitHub's default applies). Before 1.0.0 all releases are pre-releases, so this has no effect. Computinglatestlike cloud-registry does would be a separate change.--generate-notesand has no previous-release step). This is unlikely with one release run at a time, and it is kept minimal here.state=<state>(aGITHUB_OUTPUTline) and the job strips the prefix. This is kept identical to cloud-registry's script.mktempfile: GitHub-hosted runners are not reused.Open questions
None.
Closes #451
🤖 Generated with Claude Code
Summary by Sourcery
Make the GitHub release workflow robust to immutable releases and reruns by validating existing assets and publishing drafts only after uploads complete.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: