Skip to content

feat(publish-release): attach release assets - #79

Merged
uniqueg merged 4 commits into
mainfrom
feat/publish-release-assets
Nov 15, 2026
Merged

uniqueg merged 4 commits into
mainfrom
feat/publish-release-assets

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds the input assets to the shared publish-release action: files to attach to the GitHub release, one path per line.

  • The files are passed to gh release create <tag> ... -- <files>. With assets, gh creates 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.
  • The files are checked before any API call: regular files, distinct file names (GitHub names assets after them), no # (which gh reads as a display label). Not with check-only, which runs before the files are built.
  • A re-run passes for an existing published release only if it also has an asset of each file's name (names only, not content).
  • README (input, behaviour, example) and action.yml updated.

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-only ignores assets; existing release counts as ours only with all asset names; ASSETS parsing in main).
  • pre-commit run on the changed files: all hooks passed (check-github-actions, markdownlint, gitleaks).
  • gh's draft-upload-publish-cleanup behaviour was read from pkg/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:

  • Add support for attaching validated release assets through the shared publish-release action, including draft upload and publish handling.

Bug Fixes:

  • Ensure reruns recognize an existing release only when all requested assets are present and their reported digests match when available.

Enhancements:

  • Document asset configuration, validation rules, immutable-release behavior, and rerun semantics.

Documentation:

  • Update publish-release documentation with asset configuration and usage examples.

Tests:

  • Add coverage for asset parsing, validation, release creation, check-only behavior, and existing-release matching.

uniqueg and others added 3 commits November 15, 2026 20:23
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>
@sourcery-ai

sourcery-ai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Add the public assets input to the action and pass it to the publish script through the environment.

  • actions/publish-release/action.yml L54-61, L89

Implementation

Parse, validate, upload, and verify configured assets, including chunked SHA-256 checks for existing releases.

  • actions/publish-release/publish.py L633-673, L721-731, L737-760 (+7 small edits)

Documentation

Document how to configure assets and explain their validation, rerun, and draft-publication behavior.

  • actions/publish-release/README.md L108-114, L146-159 (+2 small edits)

Tests

Cover asset parsing, validation, upload arguments, check-only handling, and verification of existing-release assets.

  • tests/publish-release/test_publish.py L244-249, L661-765, L967-982 (+3 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@uniqueg
uniqueg marked this pull request as ready for review November 15, 2026 21:30
@sourcery-ai

sourcery-ai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit dfcdca1

#77 feat(publish-release): attach release assets · 4 of 5 met · 1 to check by hand

# Requirement Status Notes
1 Add an optional assets input that attaches files by creating a draft, uploading the files, and publishing afterward. ✅ Met The input is wired through action.yml; publish passes the paths after -- to gh release create.
2 Check assets before API calls, except with check-only. ✅ Met check_assets checks file validity, duplicate names, and #; publish skips these checks with check_only.
3 A rerun passes for an existing release only if it has all configured assets. ✅ Met _is_ours requires each configured asset name and checks its SHA-256 when GitHub reports a digest.
4 Update the README and tests. ✅ Met The README documents and demonstrates assets; tests cover parsing, validation, upload arguments, check-only, and reruns.
5 Release as v1.2.0 so Krini can pin it. 👀 Check by hand (external system) Check whether v1.2.0 of this repository has been published for Krini to pin.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 is free for open source - if you like our reviews please consider sharing them ✨

Comment thread actions/publish-release/publish.py Resolved
Comment thread actions/publish-release/publish.py Resolved
Comment thread actions/publish-release/publish.py Resolved
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>
@uniqueg
uniqueg merged commit f1448ae into main Nov 15, 2026
7 checks passed
@uniqueg
uniqueg deleted the feat/publish-release-assets branch November 15, 2026 21:44
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.

feat(publish-release): attach release assets

1 participant