From 347b4b0a301a6d36ad2845ae4190d06fe35cf1c6 Mon Sep 17 00:00:00 2001 From: Blair Hamilton Date: Mon, 23 Nov 2026 10:36:00 -0500 Subject: [PATCH] build: ship the Homebrew formula as a source build with bottles GoReleaser has deprecated `brews`, and the formula it wrote only unpacked a prebuilt archive with `bin.install`. homebrew_bottles writes the formula the way homebrew-core ships a CLI instead: its url is the release's source archive, its install `go build`s the pre-commit binary with the release's main package, ldflags and CGO_ENABLED=0, and a bottle block pours bottles made from the release's darwin and linux binaries, so a normal install still downloads a binary while `brew install -s` builds from source. The publisher exists only in blairham/goreleaser (proposed upstream as goreleaser/goreleaser#7342), and official GoReleaser rejects a config that names it. release.yml therefore passes goreleaser-ref, the input blairham/.github added in v0.0.4, to run the fork; every shared-workflow pin moves to v0.0.4 together. The old `install` is gone because here it would be the source-build step, and `source` is enabled to produce the archive the formula's url points at. --- .github/workflows/ci.yml | 4 ++-- .github/workflows/release.yml | 4 +++- .goreleaser.yaml | 32 +++++++++++++++++++------------- AGENTS.md | 4 ++-- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6c75ad..0a27f00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ concurrency: jobs: ci: name: CI - uses: blairham/.github/.github/workflows/go-ci.yml@2a975269ebbb74aa0b4ec96f45773d7d68cc7bcc # v0.0.3 + uses: blairham/.github/.github/workflows/go-ci.yml@ed30c1599f3dae98165801429893d397069b433c # v0.0.4 with: # The Makefile's test target: the race detector, verbose. test-command: make test @@ -50,7 +50,7 @@ jobs: # classified rather than waiting for all of go-ci. changes: name: Changes - uses: blairham/.github/.github/workflows/go-changes.yml@2a975269ebbb74aa0b4ec96f45773d7d68cc7bcc # v0.0.3 + uses: blairham/.github/.github/workflows/go-changes.yml@ed30c1599f3dae98165801429893d397069b433c # v0.0.4 # Parity is this project's entire claim, so a change that breaks it fails # before review rather than after a merge to main. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c109a83..2ea70bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,10 +40,12 @@ jobs: # workflow's OIDC identity. id-token: write attestations: write # store the provenance in the repository's attestations - uses: blairham/.github/.github/workflows/go-release.yml@2a975269ebbb74aa0b4ec96f45773d7d68cc7bcc # v0.0.3 + uses: blairham/.github/.github/workflows/go-release.yml@ed30c1599f3dae98165801429893d397069b433c # v0.0.4 with: tag: ${{ inputs.tag }} snapshot: ${{ inputs.dry-run == true }} + # blairham/goreleaser, for homebrew_bottles (goreleaser/goreleaser#7342). + goreleaser-ref: 6b2bad9d43ac7c6469cd2607a8b79bbbcbbc4b80 test-command: make test secrets: # A PAT with contents:write on blairham/homebrew-tap, so the formula can diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 23f37f2..719f879 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -120,34 +120,40 @@ changelog: - '^test:' - '^chore:' -# A formula, not a cask. This is a CLI binary with no bundle, no installer and -# no service; `brew test` is worth keeping, and formulae work on Homebrew for -# Linux exactly as they do on macOS — which matters here, since this binary is -# what CI runs on Linux runners. +# The formula builds from the source archive below (`brew install -s`) and +# pours bottles made from the release's darwin and linux binaries, the way +# homebrew-core ships a CLI: a formula, not a cask, and not a formula that only +# downloads a prebuilt archive. A formula rather than a cask because this is a +# CLI binary with no bundle, no installer and no service; `brew test` is worth +# keeping, and formulae work on Homebrew for Linux exactly as they do on macOS, +# which matters here, since this binary is what CI runs on Linux runners. # -# GoReleaser marks `brews` deprecated in favor of `homebrew_casks`, on the -# grounds that formulae installing pre-compiled binaries are "hackyish" and -# were only needed because Linuxbrew could not handle casks. There is no -# announced removal date, and the Linuxbrew limitation is not our reason for -# using them. +# homebrew_bottles replaces GoReleaser's deprecated `brews`. It comes from +# blairham/goreleaser (goreleaser/goreleaser#7342), which release.yml selects +# with goreleaser-ref; official GoReleaser rejects this key. Its `install` is +# the build-from-source step and is generated from the build below (main, +# ldflags, CGO_ENABLED), so none is written here. # # Note there is no quarantine hook here: casks flag their downloads with # com.apple.quarantine and need it stripped, formulae do not. -brews: +homebrew_bottles: - name: pre-commit + ids: + - pre-commit repository: owner: blairham name: homebrew-tap token: "{{ .Env.HOMEBREW_TAP_TOKEN }}" - directory: Formula homepage: https://github.com/blairham/go-pre-commit description: A fast Go reimplementation of pre-commit license: Apache-2.0 - install: | - bin.install "pre-commit" test: | system "#{bin}/pre-commit", "--version" +# The tarball the formula's `url` points at, for building from source. +source: + enabled: true + release: draft: false replace_existing_draft: true diff --git a/AGENTS.md b/AGENTS.md index c649999..a351750 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -93,14 +93,14 @@ The synced config files (`.golangci.yml`, `.pre-commit-config.yaml`, `.editorcon **The repo-root `action.yml` is a public composite action.** It downloads the release binary and runs hooks — a drop-in for `pre-commit/action` with no Python setup. `aws-sso-config`, `aws-config-management`, and `ghorg` consume it in their own CI, so a breaking change to its inputs (`version`, `extra_args`, `cache`, `install-only`) breaks those repos. The `pre-commit` CI job dogfoods it against this repo. -Releases: move `CHANGELOG.md`'s `[Unreleased]` under the version, push a `v*` tag → `release.yml` calls blairham/.github's `go-release.yml`, which runs the tests, then GoReleaser (`.goreleaser.yaml`) builds, signs, and notarizes, updates `blairham/homebrew-tap`, attests provenance, and publishes the tag's CHANGELOG section as the notes; then the moving `v4` alias tag follows. +Releases: move `CHANGELOG.md`'s `[Unreleased]` under the version, push a `v*` tag → `release.yml` calls blairham/.github's `go-release.yml`, which runs the tests, then GoReleaser (`.goreleaser.yaml`) builds, signs, and notarizes, updates the `pre-commit` formula in `blairham/homebrew-tap` (a source build plus bottles of the release binaries, `homebrew_bottles`), attests provenance, and publishes the tag's CHANGELOG section as the notes; then the moving `v4` alias tag follows. ## Toolchain - `go.mod`'s `go` directive is authoritative and must match `.tool-versions`' `golang` pin **exactly** — enforced by the `check-go-version-sync` hook from [blairham/pre-commit-hooks](https://github.com/blairham/pre-commit-hooks), pinned by `rev` in `.pre-commit-config.yaml` - golangci-lint and gofumpt are pinned in `go.mod`'s `tool` block — invoke as `go tool `, never a separately installed binary - Keep the `golangci-lint` pre-commit `rev` and the `go.mod` tool pin in lockstep -- goreleaser is pinned in `.tool-versions`, not `go.mod` +- goreleaser is pinned in `.tool-versions`, not `go.mod`. `.goreleaser.yaml` uses `homebrew_bottles`, which only the [blairham/goreleaser](https://github.com/blairham/goreleaser) fork parses (goreleaser/goreleaser#7342): official GoReleaser rejects the config, so `release.yml` passes `goreleaser-ref` to run the fork, and a local check or snapshot needs a build of that fork - At runtime the tool needs **git ≥ 2.31** (`ls-files --deduplicate`), the same floor as upstream; a change that uses a newer git feature must raise it in README.md and docs/parity.md too ## Key Dependencies