Skip to content

fix: replace deprecated cask postflight hook with postflight_steps - #25

Merged
KristofferRisa merged 1 commit into
KristofferRisa:mainfrom
pcriv:fix-cask-postflight-deprecation
Sep 14, 2026
Merged

KristofferRisa merged 1 commit into
KristofferRisa:mainfrom
pcriv:fix-cask-postflight-deprecation

Conversation

@pcriv

@pcriv pcriv commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace homebrew_casks[0].hooks.post.install with custom_block so the generated cask emits postflight_steps do ... end instead of the deprecated postflight do ... end stanza (Cask/InstallSteps cop). GoReleaser's hooks field on the pinned ~> v2 release always renders the old Ruby stanza with no config-level way to emit postflight_steps, so the block is written directly.
  • Shorten the cask description from 83 to 64 characters to clear Homebrew's Cask/Desc 80-character limit, flagged by the same brew style run.

Test plan

  • make check passes locally (fmt, vet, mod verify, race tests)
  • YAML validated (ruby -ryaml)
  • Emitted Ruby verified to match the issue's suggested postflight_steps / on_macos / chdir: "." shape exactly
  • Manual brew install --cask smoke 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

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 KristofferRisa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
KristofferRisa merged commit ff346f1 into KristofferRisa:main Sep 14, 2026
5 checks passed
@pcriv
pcriv deleted the fix-cask-postflight-deprecation branch September 14, 2026 20:22
@pcriv

pcriv commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@KristofferRisa any idea when you will release this fix?

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.

Homebrew cask uses deprecated postflight stanza, warns on every brew command

2 participants