Skip to content

ci: publish releases through a draft so a failed upload cannot ship - #9

Merged
bnayahu merged 5 commits into
mainfrom
ci/atomic-release-publish
Aug 11, 2026
Merged

ci: publish releases through a draft so a failed upload cannot ship#9
bnayahu merged 5 commits into
mainfrom
ci/atomic-release-publish

Conversation

@bnayahu

@bnayahu bnayahu commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Closes #4

Problem

release.yml published with a single call that both created the release object and uploaded its assets:

gh release create "$GITHUB_REF_NAME" Primary.exe SHA256SUMS.txt --title ... --notes-file notes.md --verify-tag

If an upload failed partway, the release could exist — publicly, and as "latest" — with missing or incomplete assets. Every correctness gate already runs before this call, so a bad build can't get here; only a network or API failure can. But a published release is immediately visible, so the window mattered.

Change

The issue suggested draft → upload → publish. That's implemented, plus a gate before publishing:

  1. Create as --draft, no assets. Drafts are hidden from users and from the "latest release" API.
  2. Upload the assets with --clobber, so a rerun after a partial upload replaces the incomplete asset instead of failing on "already exists".
  3. Verify, then publish with gh release edit --draft=false.

Step 3 accepts an asset only when GitHub reports state == "uploaded" and its reported size matches the local file. Presence alone would not catch a truncated upload, which is the exact failure mode the issue describes. If either asset falls short, the job fails with the release still a draft — never published.

--verify-tag is retained on the create step.

Recovery is simpler now

The issue's procedure required deleting the tag and re-tagging. A failure now leaves only a draft, and the tag is already correct:

gh release delete "$TAG"   # tag survives; no re-tag needed
# fix the cause, then rerun the workflow

This is recorded in a comment in the workflow.

Verification

  • release.yml parses as valid YAML; step order is create-draft → upload → verify-and-publish.
  • The verification logic was rehearsed read-only against the live v1.0.0 release: both assets matched exactly (Primary.exe 121856/121856, SHA256SUMS.txt 78/78) → would publish.
  • Negative cases were exercised directly: a missing asset, a name that only looks right, an empty asset list, and a size mismatch each produce exit 1 and leave the release unpublished.

Not covered: this can't be end-to-end tested without cutting a real tag, so the create/upload/edit sequence itself is exercised for the first time on the next release. The failure mode if something is wrong is a stuck draft — not a bad publish.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Pressing OK could call CheckAndApplyAutoSwitch() three times: once in the
auto-switch settings block, once in the base-mouse-count block, and once
in the forced re-apply after the cached device state is discarded. Each
call enumerates raw input devices, retrying GetRawInputDeviceList up to
three times, so a single click cost up to three enumerations.

The repeats were harmless — the direction is persisted before all three
calls and ApplyMouseOrientation() sets an absolute value rather than
toggling — but only the last call could do useful work in the common
case, since the first two early-return on unchanged state.

Remove the two earlier calls and keep the forced re-apply at the end of
the handler. By that point every setting the check reads is persisted, so
one pass applies them all; the first call previously ran before
SetBaseMouseCount(), so it could not see a changed base count anyway.

Dropping the base-mouse-count call also stops a re-apply from running
when the auto-switch flag itself failed to persist: that call was gated
on autoSwitchEnabled alone, not on autoSwitchWritten. The surviving call
is gated on both, matching 3a00a42.

Closes #2

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Jonathan Bnayahu <bnayahu@il.ibm.com>
build.yml declared no permissions: block, so the workflow ran with the
default GITHUB_TOKEN permissions. The job only checks out the repository,
builds, and uploads an artifact, so read access to contents is all it
needs. actions/upload-artifact authenticates with the Actions runtime
token rather than GITHUB_TOKEN, so it is unaffected.

Nothing was broken; this narrows the token to what the job actually uses.

The comment warns against copying the block into release.yml, which
genuinely needs contents: write for `gh release create`.

Closes #3

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Jonathan Bnayahu <bnayahu@il.ibm.com>
…order

Both workflows derived the source version with a single alternation piped
through `paste`:

  grep -oP 'APP_VERSION_(MAJOR|MINOR|PATCH)\s+\K\d+' ... | paste -sd.

That takes the macros in the order they appear in the header rather than
in semantic order. They currently appear as MAJOR, MINOR, PATCH on
adjacent lines, so the result is correct today, but nothing enforced it —
reordering them silently produced a transposed version string.

The existing failure mode was fail-closed: release.yml's tag gate rejects
a mismatch loudly rather than publishing something mislabelled. This makes
the extraction correct in the first place, so a reorder is a non-event
instead of a confusing release failure.

Extract each component by name, and assert all three are non-empty — the
old form would emit a short "1.2" if a macro went missing, which could
then match a substring of the binary's version strings.

Closes #6

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Jonathan Bnayahu <bnayahu@il.ibm.com>
primary.rc references primary.manifest as an opaque file, so windres never
runs the preprocessor over it and its assemblyIdentity version cannot be
derived from APP_VERSION_*. It has to be bumped by hand, and nothing
enforced that — the only safeguard was a manual release-checklist step.

Assert it in CI instead: compare the manifest's assemblyIdentity version
against MAJOR.MINOR.PATCH.0 from app_strings.h, in build.yml (every push
and PR) and in release.yml (refuse to ship a mismatch). Drift now fails
loudly instead of shipping silently.

Of the options in the issue, this leaves the build path untouched.
Generating the manifest from a template in build.sh was rejected because
README.md documents a direct windres/g++ invocation that bypasses
build.sh — build.yml verifies that command still works — so a generated
manifest would break or stale out that documented path.

The manifest comment now records that CI enforces the match, and that the
check expects name= and version= on one line.

Closes #5

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Jonathan Bnayahu <bnayahu@il.ibm.com>
`gh release create` created the release object and uploaded both assets in
one invocation, so an upload that failed partway could leave a published
release with missing or truncated downloads. Every correctness gate (tag
and source version match, warning check, binary version assertion) already
runs before this point, so only a network or API failure could cause it —
but the window was real and users see published releases immediately.

Split publishing into three steps:

  1. create the release as a --draft, with no assets
  2. upload the assets (--clobber, so a rerun after a partial upload
     replaces the incomplete asset instead of failing on "already exists")
  3. verify both assets, then flip --draft=false

A draft is hidden from users and from the "latest release" API, so a
failure at step 1 or 2 no longer produces a visible partial release.

Step 3 accepts an asset only when GitHub reports state == "uploaded" and
its size matches the local file, which catches a truncated upload as well
as a missing one. Anything short of that fails the job with the release
still a draft.

Each step is now independently retryable, and recovery no longer needs a
re-tag: delete the leftover draft with `gh release delete "$TAG"` and rerun.

Closes #4

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Jonathan Bnayahu <bnayahu@il.ibm.com>
@bnayahu
bnayahu force-pushed the ci/atomic-release-publish branch from a04a3d4 to 3fe62db Compare August 11, 2026 18:43
@bnayahu
bnayahu merged commit 3fe62db into main Aug 11, 2026
1 check passed
@bnayahu
bnayahu deleted the ci/atomic-release-publish branch August 11, 2026 18:47
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.

release.yml: gh release create can leave a partial release if asset upload fails

1 participant