Repository navigation
feat(publish-release): attach release assets - #79
Conversation
Add the input `assets` (one path per line): the files are passed to `gh release create`, which creates the release as a draft, uploads them, and publishes it only then, deleting the draft if that fails. Repositories with immutable releases can't add assets after publishing, so this is the only way to attach e.g. a packaged Helm chart while using the shared action. The files are checked before any API call (regular files, distinct names, no `#`, which gh reads as a label), but not with `check-only`, which runs before they are built. A re-run passes for an existing release only if it has all the assets. First user: elixir-cloud-aai/krini#94. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reject asset file names that GitHub would rename (only letters, digits, '.', '_' and '-', no leading or trailing '.'), so that a re-run finds them by name. A re-run now counts an existing release as ours only if each asset's digest, where GitHub reports one, is the SHA-256 of the local file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideAPIAdd the public
ImplementationParse, validate, upload, and verify configured assets, including chunked SHA-256 checks for existing releases.
DocumentationDocument how to configure assets and explain their validation, rerun, and draft-publication behavior.
TestsCover asset parsing, validation, upload arguments, check-only handling, and verification of existing-release assets.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Linked issuesChecked at commit dfcdca1 #77 feat(publish-release): attach release assets · 4 of 5 met · 1 to check by hand
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="actions/publish-release/publish.py" line_range="754" />
<code_context>
+ Returns:
+ The hexadecimal digest.
+ """
+ return hashlib.sha256(path.read_bytes()).hexdigest()
+
+
</code_context>
<issue_to_address>
**Large assets exhaust runner memory**
When a rerun checks an existing release containing a large requested asset, `_sha256` calls `Path.read_bytes()` and loads the entire asset into memory, so the runner is terminated and the rerun fails instead of recognizing the published release.
Hash the asset incrementally in chunks instead of reading it all at once.
</issue_to_address>
### Comment 2
<location path="actions/publish-release/publish.py" line_range="896-898" />
<code_context>
file.name,
f"--prerelease={str(prerelease).lower()}",
*([] if latest is None else [f"--latest={str(latest).lower()}"]),
+ # With assets, gh creates a draft, uploads them, then
+ # publishes it (and deletes the draft if either fails)
+ *(["--", *map(str, settings.assets)] if settings.assets else []),
]
)
</code_context>
<issue_to_address>
**Older release becomes latest**
When a job for an older version reads the release list, then a job for a higher version publishes while the older job is uploading its assets, `publish` computes `latest` from the initial release list and passes `--latest=true` to `gh release create`. While this job uploads assets, a job for a higher version can publish; this job then publishes the older release as latest, so users see the wrong latest release.
Re-evaluate or serialize latest-release selection after uploads and immediately before publication, rather than applying a stale `--latest=true` decision.
</issue_to_address>
### Comment 3
<location path="actions/publish-release/publish.py" line_range="737-741" />
<code_context>
and (text == notes or text[len(notes) :].startswith("\n\n"))
and release.get("name") == (settings.title or settings.tag)
and bool(release.get("prerelease")) is prerelease
+ and all(
+ path.name in digests
+ and digests[path.name] in ("", f"sha256:{_sha256(path)}")
+ for path in settings.assets
+ )
)
</code_context>
<issue_to_address>
**Rerun documentation misstates asset checks**
When a caller relies on `publish`'s documented rerun rule, `publish` raises `ReleaseError` when a requested asset is missing or its reported digest differs, but the `Raises` documentation says an existing release passes based only on notes, title, and pre-release flag, misleading callers about rerun behavior.
Update the `Raises` documentation to say that reruns also require the requested assets and their reported digests to match.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the configured paths point to the wrong files or include unintended content, those files are uploaded to a published GitHub release and may be publicly downloadable. Reverting the action does not retract an already published release or its assets; they would need to be removed separately.
Blocking findings: actions/publish-release/publish.py:754, actions/publish-release/publish.py:898
Sourcery review: hash large assets in chunks instead of reading them into memory, and document the asset checks in publish's Raises. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Adds the input
assetsto the sharedpublish-releaseaction: files to attach to the GitHub release, one path per line.gh release create <tag> ... -- <files>. With assets,ghcreates the release as a draft, uploads the files, and publishes it only then; if an upload or the publishing fails, it deletes the draft. So repositories with immutable releases (whose assets can't be added after publishing) get complete releases.#(whichghreads as a display label). Not withcheck-only, which runs before the files are built.action.ymlupdated.First user: elixir-cloud-aai/krini#94 (Krini 0.1.0 attaches its packaged Helm chart and the chart's Sigstore bundle). It needs a release of this repo (e.g. v1.2.0) to pin.
Closes #77
Verification
bash tests/publish-release/test.sh: 49 tests passed (new: assets passed after--, also with spaces and a leading-; invalid assets fail before any call;check-onlyignores assets; existing release counts as ours only with all asset names;ASSETSparsing inmain).pre-commit runon the changed files: all hooks passed (check-github-actions, markdownlint, gitleaks).gh's draft-upload-publish-cleanup behaviour was read frompkg/cmd/release/create/create.go(cli/cli trunk); the end-to-end check is the krini fork dry run (v0.0.1-rc1).Declined review findings
None: the round-1 findings (asset names that GitHub renames, digest comparison on re-runs, README wording, tests for leading
-) are fixed.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Support publishing complete GitHub releases with optional validated assets.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: