Skip to content

Use postflight_steps for the thv Homebrew cask hook - #6870

Merged
rdimitrov merged 2 commits into
mainfrom
claude/cask-postflight-steps
Oct 19, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
claude/cask-postflight-steps

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Homebrew 7.0.10 deprecated the Ruby postflight block in casks in favour of postflight_steps. Our thv cask uses postflight to remove macOS's quarantine flag, so every stacklok/tap user now sees this whenever brew loads the cask (brew update, brew list, brew upgrade, brew info):

Warning: Calling `postflight` is deprecated! Use `postflight_steps` instead.

GoReleaser's hooks.post.install can only generate the old postflight block. Its replacement, install_steps, is only in v2.19 nightlies, and the v2.18 our releases use rejects it.

  • Replace hooks.post.install with a custom_block that writes the same quarantine removal as a postflight_steps stanza, on macOS only.
  • The stanza body is exactly what GoReleaser v2.19's install_steps generates (goreleaser/goreleaser@4ebadf5): run "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "{{staged_path}}/thv"]. {{staged_path}} is a Homebrew token. It is escaped in .goreleaser.yaml so GoReleaser's own templating leaves it alone.

Type of change

  • Other (describe): release config change

Test plan

  • Manual testing (describe below)

  • goreleaser check passes on v2.15.4 and v2.18.3. A goreleaser release --snapshot with v2.18.3 writes a cask whose first stanza is postflight_steps, with no postflight.

  • On macOS arm64 with Homebrew 7.0.10, I installed throwaway casks from a local test tap using the v0.55.1 release tarballs:

    • Without any hook: the installed binary has com.apple.quarantine. This confirms the hook is still needed.
    • With postflight_steps: no deprecation warning on install or brew info, the quarantine flag is removed, and thv version runs.
    • With the stanza at the top of the cask, where custom_block puts it: same result.
    • Upgrade from 0.55.0 to 0.55.1: no warning, and the quarantine flag is removed from the new version.
    • The exact body GoReleaser v2.19 generates (-dr with {{staged_path}}): no warning, the quarantine flag is removed, and thv runs. xattr -dr exits 0 when the flag is already gone, so the step has no failure mode beyond a genuine xattr error.

Does this introduce a user-facing change?

Yes, for Homebrew users.

  • Before: brew prints the postflight deprecation warning whenever it loads the thv cask.
  • After: no warning. Installs and upgrades behave the same.

This applies from the next release, which is when the regenerated cask reaches the tap.

Special notes for reviewers

  • Older Homebrew: postflight_steps first shipped in Homebrew 5.1.14 (May 2026). On anything older the cask fails to load, rather than just warning. Homebrew updates itself by default, so this only affects users who disabled auto-update and haven't updated in about five months.
  • Stanza order: custom_block puts the stanza at the top of the cask. brew audit would flag that order in an official tap, but install and upgrade don't care, and I tested that order specifically.
  • Intel Macs and Linux weren't tested on hardware. Homebrew evaluates on_macos when the step runs (Homebrew::SimulateSystem.simulating_or_running_on_macos? in install_steps.rb), so Linux skips the step. Intel Macs run the same /usr/bin/xattr call as arm64. The stanza parses identically on every platform, since the DSL has no OS-specific methods.
  • Follow-up: once GoReleaser v2.19 is stable, switch custom_block to hooks.post.install_steps (using {{ .StagedPath }}). The generated stanza is identical. Only its position in the cask moves, to after binary. Notarizing the darwin builds would remove the need for the hook altogether.

🤖 Generated with Claude Code

Homebrew 7.0.10 deprecated the Ruby postflight block that
hooks.post.install generates, so every stacklok/tap user sees a
warning whenever brew loads the thv cask.

Write the quarantine-removal hook as a postflight_steps stanza via
custom_block instead. GoReleaser's own install_steps option would
generate the same stanza, but it is not in a stable release yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov
rdimitrov requested a review from JAORMX as a code owner October 19, 2026 22:57
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Oct 19, 2026
Use the same xattr -dr call with Homebrew's staged_path token that
GoReleaser's install_steps generates. -dr exits 0 when the attribute
is absent, so real failures are no longer masked by must_succeed:
false, and the later switch to install_steps changes only the
stanza's position in the cask.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Oct 19, 2026
@rdimitrov
rdimitrov merged commit 7262276 into main Oct 19, 2026
20 checks passed
@rdimitrov
rdimitrov deleted the claude/cask-postflight-steps branch October 19, 2026 23:02
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.77%. Comparing base (b5246d8) to head (038cf3a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6870      +/-   ##
==========================================
- Coverage   79.81%   79.77%   -0.05%     
==========================================
  Files         820      820              
  Lines       83723    83723              
==========================================
- Hits        66826    66788      -38     
- Misses      16892    16930      +38     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant