Skip to content

Move the cask hook to install steps and put tag notes above the changelog - #4

Merged
usmanbashir merged 2 commits into
mainfrom
goreleaser-install-steps
Oct 25, 2026
Merged

usmanbashir merged 2 commits into
mainfrom
goreleaser-install-steps

Conversation

@usmanbashir

Copy link
Copy Markdown
Owner

Summary

goreleaser-check fails on main because CI now installs GoReleaser 2.19.0. That release deprecated homebrew_casks.hooks.post.install, and goreleaser check exits 2 when a config uses deprecated properties. The first commit moves the macOS quarantine hook to install_steps, which writes Homebrew's declarative postflight_steps stanza instead of a Ruby postflight block.

The second commit puts the annotated tag's message body above the generated changelog, so the release note gets written at tag time. The release job now refuses a tag that isn't annotated.

Changes

  • .goreleaser.yaml:
    • The hook becomes install_steps, with on_macos do run "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "{{ .StagedPath }}/clau"], must_succeed: false end. GoReleaser renders {{ .StagedPath }} as Homebrew's {{staged_path}} token, which Homebrew expands at install time.
    • release.header is "{{ .TagBody }}".
  • .github/workflows/release.yml:
    • A new step after checkout runs git fetch --force --tags. It fails the job unless git cat-file -t "$GITHUB_REF_NAME" prints tag.
    • A comment at the top explains how to tag a release. Use git tag -a, with a subject line, a blank line, then the note. Write headings as bold text, because git strips # lines. Alternatively, use --cleanup=verbatim with -F, since in the editor it also keeps git's own # instructions.

The guard

The steps DSL takes no arbitrary Ruby, so File.executable? couldn't come along. Homebrew 7.0.10's source (install_steps.rb, system_command.rb) and the Cask Cookbook's *flight_steps section settle what's supported:

  • must_succeed: false on run: supported since 6.0.16. The default is true, and a failing command aborts the install.
  • OS conditionals: on_macos and on_linux blocks, plus if_path_exists and unless_path_exists, since 6.0.12. The runner evaluates them at install time.
  • A missing executable: still an error. The spawn falls back to fork and exec, which exits 127, and that raises only when must_succeed is true.
  • Built-in quarantine handling: none. Homebrew 7 quarantines every cask download on macOS, and --no-quarantine has been removed.

So on_macos replaces the file check. must_succeed: false stays, so a macOS install still succeeds if the attribute is already gone. GoReleaser's cask docs give the same on_macos form for unsigned binaries.

Behavior notes

  • Loading the new cask needs Homebrew 6.0.16 or later, the first release whose run accepts must_succeed:. Older Homebrew fails when it loads the cask, on macOS and Linux alike. brew update brings a current Homebrew along with the new cask, so this only affects an old Homebrew with auto-update turned off.
  • Today, Homebrew 7 prints Warning: Calling postflight is deprecated! Use postflight_steps instead. every time it loads the published cask. The next release's cask doesn't trigger it.
  • A tag with only a subject line, like v0.3.0 and v0.4.0, has an empty .TagBody, so its release body is the changelog alone, as today.
  • GoReleaser joins the header and the changelog with one newline, so the raw body has no blank line before ## Changelog. A CommonMark renderer (goldmark) still renders it as a heading after a list or a paragraph. I didn't check GitHub's own renderer.

Release note draft

Homebrew no longer warns about postflight. The cask now uses Homebrew's install steps. Installing or upgrading it needs Homebrew 6.0.16 or later, which brew update provides.

Test plan

  • goreleaser check with v2.19.0, the binary CI downloads: exits 2 on main with the CI error, and 0 on this branch.
  • goreleaser release --snapshot --clean writes postflight_steps do on_macos do run "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "{{staged_path}}/clau"], must_succeed: false end end to dist/homebrew/Casks/clau.rb. Homebrew 7.0.10 loads it as a run step with an on: macos guard and allow_failure: true.
  • Linux install on Homebrew 7.0.10 (Fedora, no /usr/bin/xattr), using renamed copies of the snapshot cask in a throwaway local tap:
    • The generated block installs, and the step is skipped.
    • Without on_macos, must_succeed: false still installs. Homebrew prints env: '/usr/bin/xattr': No such file or directory.
    • With no guard and the default must_succeed, the install fails with exit 127 and is rolled back.
  • macOS is untested; there's no Mac here. On macOS the guard is true and the xattr step should run. That path hasn't been exercised.
  • Release header. --snapshot skips the changelog and the release, and release.header is only rendered while publishing, so a snapshot can't show it. Instead, I ran the real v2.19.0 goreleaser release against a local stand-in for the GitHub API, set through github_urls. It ran in a throwaway clone with a local v0.5.0 tag, never pushed. I read the body it sent:
    • Annotated tag: the note sits above ## Changelog, and git has already stripped a # line from it.
    • Lightweight tag: the tagged commit's body goes out as the note. The new step blocks this case.
    • Subject-only tag: the changelog alone.
  • The new step's run: block, extracted with yq and run under bash -e against a local bare repo:
    • An annotated tag passes.
    • A lightweight tag fails with the ::error::.
    • An annotated tag that was replaced locally by a lightweight ref, as checkout can do, passes after git fetch --force --tags.
  • actionlint with shellcheck is clean on both workflows. go test -count=1 ./..., go vet ./... and gofmt -l . are clean.
  • The release workflow itself only runs on the next real tag.

GoReleaser 2.19 deprecated hooks.post.install, which writes a Ruby
postflight block, and goreleaser check exits 2 on deprecated
properties. Homebrew 7 also warns about postflight every time it
loads the cask. install_steps writes the declarative postflight_steps
stanza instead.

The steps DSL takes no arbitrary Ruby, so the File.executable? guard
becomes on_macos, which Homebrew evaluates at install time. A run step
whose executable is missing still fails the install with exit 127, so
Linux has to skip the step rather than run it. must_succeed: false
keeps macOS installs alive when the attribute is already absent.

Loading the cask needs Homebrew 6.0.16 or later, the first release
whose run step takes must_succeed.
release.header renders .TagBody, so a note written in the tag message
at tag time lands above GoReleaser's generated changelog. A tag with
only a subject line has no body, and its release stays as before.

The .TagBody of a lightweight tag is the tagged commit's message body,
which would go out as the note without any warning. The release job
now fetches the tag objects again, in case checkout replaced them with
lightweight refs, and fails unless the pushed ref is an annotated tag.

The tagging steps are written down at the top of release.yml.
@usmanbashir
usmanbashir marked this pull request as ready for review October 25, 2026 09:42
@usmanbashir
usmanbashir merged commit 82aa108 into main Oct 25, 2026
4 checks passed
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.

1 participant