Skip to content

Add undraft-release to upload into an existing draft without publishing it - #2521

Open
gerchowl wants to merge 1 commit into
axodotdev:mainfrom
gerchowl:undraft-release
Open

gerchowl wants to merge 1 commit into
axodotdev:mainfrom
gerchowl:undraft-release

Conversation

@gerchowl

Copy link
Copy Markdown

Closes #2520.

What

A new global-only setting, next to create-release:

[dist]
create-release = false
undraft-release = false   # new; default true

With create-release = false and undraft-release = false, the publish step uploads dist's artifacts into the existing draft GitHub Release (gh release upload <tag> artifacts/* --clobber) and does not run gh release edit <tag> --draft=false. The release stays a draft, so another tool that owns it can attach more assets and publish it later. The default (true) leaves generated CI byte-for-byte unchanged.

Changes

  • Config: v0 undraft-release maps to v1 hosts.github.undraft (in the layer, the final config and ApplyLayer), with the usual "only accepted in workspace.metadata" warning. dist init round-trips the key.
  • backend/ci/github.rs: exposes undraft_release to the templates. release_command is unchanged.
  • partials/publish_github.yml.j2: adds an upload-only branch for create-release = false plus undraft-release = false. It uses --clobber so re-runs are idempotent, and passes --repo "$REPO" when github-releases-repo is set. release_command is rendered only when creating or undrafting.
  • release.yml.j2: the header comment no longer claims the release will be undrafted in this mode.
  • Book: a new undraft-release entry in the config reference, and a note in ci/customizing.md.
  • Tests: a new axolotlsay_edit_existing_no_undraft snapshot, the same config as axolotlsay_edit_existing plus undraft-release = false. Against the axolotlsay_edit_existing snapshot, the diff is exactly the header comment plus upload … --clobber replacing upload … + gh release edit … --draft=false. The existing snapshot is unchanged.

Testing

  • cargo test --workspace -- --test-threads=1 (no nextest, per CONTRIBUTING): everything passes except axolotlsay_basic. That test fails identically on unmodified main on my machine, because dist build -aglobal reports missing packaging tools. cargo clippy --workspace --all-targets and cargo fmt --check are clean.
  • End to end with a build of this branch on a toy workspace (ci = "github", create-release = false, undraft-release = false):
    • dist generate emits gh release upload … --clobber, with zero occurrences of --draft=false. dist generate --check is clean, and dist init --yes keeps the key.
    • The same holds with github-release = "announce" and with github-releases-repo (where the upload gets --repo "$REPO").
    • I executed the generated step's script against a fake gh modelling an immutable-once-published draft. With the new option, two consecutive runs both succeed and the release stays a draft. With the default, the release is undrafted and a re-run hits HTTP 422: Cannot upload assets to an immutable release, which is the failure mode that motivated this.

Notes for review

  • The name undraft-release mirrors create-release. Happy to rename (e.g. github-release-undraft).
  • The config docs say "since 1.0.0", assuming that's the next release; please adjust.
  • I left CHANGELOG.md alone, since it looks maintainer-written at release time.
  • While here I noticed that the existing undraft path's gh release upload doesn't pass --repo "$REPO" when github-releases-repo is set, so it uploads to the current repo. I haven't changed that path, to keep this PR scoped; I can send a separate fix if you'd like.

…hing it

With `create-release = false`, dist uploads into an existing draft GitHub
Release and then always undrafts it. `undraft-release = false` (default
true) keeps the upload and skips the `gh release edit --draft=false`, so
another tool that owns the release can attach more assets and publish it
itself. Uploads use `--clobber` in this mode so re-runs are idempotent.

This branch has not been deployed

No deployments
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.

Option to upload into an existing draft GitHub Release without undrafting it

1 participant