Repository navigation
fix: replace deprecated cask postflight hook with postflight_steps - #25
Conversation
GoReleaser's hooks.post.install always renders the legacy Ruby `postflight do` stanza, which Homebrew's Cask/InstallSteps cop now flags as deprecated on every brew command that loads the tap. There is no hooks field that emits the modern `postflight_steps` DSL yet on the pinned "~> v2" GoReleaser release, so the stanza is written directly via custom_block instead. Also shortens the cask description under Homebrew's 80-char limit, flagged by the same brew style run. Closes KristofferRisa#24
KristofferRisa
left a comment
There was a problem hiding this comment.
Thanks for this — and for tracking down the root cause in #24 rather than just patching the tap.
I verified the change locally: generated the cask both ways with goreleaser 2.18.0 (matching the pinned ~> v2) and ran brew style on each in a scratch tap.
The fix works. The emitted block matches the shape from #24 exactly, the postflight deprecation is gone, and the shortened desc clears Cask/Desc.
One trade-off worth recording. custom_block is injected at the very top of the cask body, before version — not where the old postflight sat (after binary). That puts everything below it out of canonical stanza order:
main: 1 offense (Cask/Desc)
PR #25: 9 offenses (Cask/StanzaOrder × 9)
It's one misplacement reported nine times, and it's cosmetic — style cops only, no user-facing warning, no effect on installs. So this is still a clear net improvement over the deprecation spam. But it does mean the "clears brew style" framing in the description isn't quite right; could you soften that to note the ordering trade instead? custom_block is a plain string field in the GoReleaser schema with no position control, so top-of-cask is the only insertion point available — nothing you can do about it here.
Upstream is fixing this properly. goreleaser/goreleaser#6873 (by caarlos0) adds hooks.{pre,post}.{install,uninstall}_steps and deprecates the raw-Ruby hooks. I checked the golden files on that branch: it emits postflight_steps in the correct stanza position, and adds a .StagedPath template field so the hook keeps the absolute path instead of the relative "powerctl" + chdir: "." form. It's slated for v2.19 (goreleaser/goreleaser#6870), still unmerged as of today.
Plan: I'd like to merge this now — the deprecation warning is what users actually hit, and this kills it today — then swap to hooks.post.install_steps when v2.19 ships. Could you add a line to the config comment pointing at goreleaser/goreleaser#6873 so the cleanup is easy to find later? Something like:
# Revert to hooks.post.install_steps once GoReleaser v2.19 ships
# (goreleaser/goreleaser#6873) — that emits the stanza in the right
# position and restores the absolute staged path.With that and the description tweak, this is good to go. The unchecked brew install --cask smoke test is fine to leave — I'll catch it on the next release.
|
@KristofferRisa any idea when you will release this fix? |
Summary
homebrew_casks[0].hooks.post.installwithcustom_blockso the generated cask emitspostflight_steps do ... endinstead of the deprecatedpostflight do ... endstanza (Cask/InstallStepscop). GoReleaser'shooksfield on the pinned~> v2release always renders the old Ruby stanza with no config-level way to emitpostflight_steps, so the block is written directly.descriptionfrom 83 to 64 characters to clear Homebrew'sCask/Desc80-character limit, flagged by the samebrew stylerun.Test plan
make checkpasses locally (fmt, vet, mod verify, race tests)ruby -ryaml)postflight_steps/on_macos/chdir: "."shape exactlybrew install --casksmoke test against the next real release (untested end-to-end — flagged in review, same caveat the issue author noted for their own manual verification)Closes #24
🤖 Generated with Claude Code