Skip to content

bug: publish-cask patches the wrong stanza's sha256, corrupting the Homebrew cask #87

Closed

Description

@mpeter

Summary

The publish-cask job in .github/workflows/release.yml patches the wrong sha256 line in the Homebrew cask. brew install unbound-force/tap/replicator is currently broken on macOS arm64 and Linux amd64 at v0.5.0.

This is a distinct defect from #81 (which addressed the TOCTOU/skip gap by extracting publish-cask). That extraction was correct; the awk targeting inside it is not.

Root cause

GoReleaser emits each stanza as sha256 then url, so the darwin_arm64 marker appears after the sha256 line it belongs to:

on_macos do
  on_arm do
    sha256 "..."                      # line 7  <- belongs to darwin
    url ".../darwin_arm64.tar.gz"     # line 8  <- marker seen here

The awk scans forward from the marker for the next sha256, which is the linux_amd64 stanza's line.

Evidence (v0.5.0)

Cask line Stanza Published SHA Actual artifact SHA
7 darwin_arm64 ea3278e2… 33683ca5… ❌ stale
14 linux_amd64 33683ca5… (darwin's) db3f96fc… ❌ clobbered
18 linux_arm64 d35cf511… d35cf511… ✅

Replaying the shipped awk against the real cask reproduces exactly this: it patches line 14, not line 7.

The replicator.rb release asset is clean for both Linux stanzas — the corruption is introduced by the patch step and exists only in the tap.

Why it was not caught

The verification guard is a file-wide grep -q "sha256 \"$ARM64_SHA\"". Because the darwin SHA was written into the file (onto the linux line), the grep passed and the corrupt cask shipped.

openspec/changes/fix-homebrew-sha-mismatch/specs/release-pipeline.md already requires verification "in the correct context (associated with the darwin_arm64 section)" — that requirement is unmet by the current implementation.

Impact

  • macOS arm64: stale pre-signing checksum -> mismatch
  • Linux amd64: darwin's checksum -> mismatch
  • Linux arm64: unaffected

Fix

Bind the darwin_arm64 marker to the nearest preceding sha256 line, fail loudly when no such line exists, and make the verification stanza-aware so a mispatch cannot clear the gate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions