From 169fcc276660778fc4e33afe15d5bc1300435ae7 Mon Sep 17 00:00:00 2001 From: avison9 Date: Mon, 21 Sep 2026 19:55:36 +0100 Subject: [PATCH] The release rewrites the tap's source formula, and the install docs name both Homebrew forms avison9/homebrew-tap now carries Formula/cdclint.rb, which builds from the tagged source the way homebrew/core would, beside the cask goreleaser writes. goreleaser has no source-formula support (its formula output downloads binaries, which core refuses), so a step after it rewrites the formula's url and sha256 to this tag: the hash is of GitHub's source tarball for the tag, which GitHub keeps stable for tags. It runs only for a final release, like the major tag step, and pushes with the same token the cask uses. Homebrew resolves a name that is both a formula and a cask to the formula, so `brew install avison9/tap/cdclint` builds from source from now on and the binary is `brew install --cask avison9/tap/cdclint`. INSTALLING.md says so, on macOS and Linux, and in the uninstall table; RELEASING.md lists the new step and the two install checks. Verified: the sed rewrites exactly the url and sha256 lines of the real formula (dry run with v0.2.0's tarball); the workflow parses. --- .github/workflows/release.yml | 24 ++++++++++++++++++++++++ INSTALLING.md | 18 ++++++++++++++---- RELEASING.md | 12 ++++++++---- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7e83c4..aaa66fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,30 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + # Formula/cdclint.rb in the tap builds from the tagged source, the + # way homebrew/core would; goreleaser writes only the cask, so this + # rewrites the formula's url and sha256 to this tag. The hash is of + # GitHub's source tarball for the tag, which GitHub keeps stable for + # tags. Only for a final release, like the major tag below. + - name: Bump the tap formula + if: ${{ !contains(github.ref_name, '-') }} + shell: bash + env: + TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + run: | + set -euo pipefail + tag="$GITHUB_REF_NAME" + url="https://github.com/avison9/cdclint/archive/refs/tags/${tag}.tar.gz" + sha="$(curl -fsSL "$url" | sha256sum | awk '{print $1}')" + git clone -q --depth=1 "https://x-access-token:${TAP_TOKEN}@github.com/avison9/homebrew-tap.git" "$RUNNER_TEMP/tap" + cd "$RUNNER_TEMP/tap" + sed -i -E "s|^( url \").*(\")$|\1${url}\2|; s|^( sha256 \").*(\")$|\1${sha}\2|" Formula/cdclint.rb + grep -q "$sha" Formula/cdclint.rb + git config user.name "avison9" + git config user.email "avisonlivingstone@gmail.com" + git commit -qam "cdclint ${tag} formula" + git push -q origin HEAD:main + echo "formula: ${url} ${sha}" # `uses: avison9/cdclint@v1` needs a v1 tag that follows the newest # v1.x.y release. goreleaser does not move tags, so this does, after # the release exists and only for a final release (v1.2.3, not diff --git a/INSTALLING.md b/INSTALLING.md index 8d15536..ceaf8ee 100644 --- a/INSTALLING.md +++ b/INSTALLING.md @@ -21,8 +21,17 @@ ARM). brew install avison9/tap/cdclint ``` -Updates come with `brew upgrade`. The cask clears the quarantine attribute -after install, so Gatekeeper does not block the first run. +That builds from the tagged source, the way homebrew/core does: Homebrew +installs `go` as a build dependency (once, from a bottle), then the build +takes seconds. For the release binary instead, no Go involved: + +``` +brew install --cask avison9/tap/cdclint +``` + +Updates come with `brew upgrade` either way. The cask clears the +quarantine attribute after install, so Gatekeeper does not block the +first run; a formula build is never quarantined. **Release archive**, without Homebrew: @@ -44,10 +53,11 @@ xattr -d com.apple.quarantine /usr/local/bin/cdclint ## Linux -**Homebrew on Linux** works the same as on macOS: +**Homebrew on Linux** works the same as on macOS, formula or cask: ``` brew install avison9/tap/cdclint +brew install --cask avison9/tap/cdclint ``` **Release archive** (any distribution, no package manager needed): @@ -170,7 +180,7 @@ The GitHub Action does the first check on every run. | installed with | remove with | |---|---| -| Homebrew | `brew uninstall cdclint` | +| Homebrew | `brew uninstall cdclint`, or `brew uninstall --cask cdclint` for the cask | | release archive | delete the binary from where you put it | | Go | `rm "$(go env GOPATH)/bin/cdclint"` | | Windows archive | delete `%LOCALAPPDATA%\Programs\cdclint` and the PATH entry | diff --git a/RELEASING.md b/RELEASING.md index 675de93..5c546ad 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -33,12 +33,16 @@ The `release` workflow then: 5. creates the GitHub Release with a changelog from the commits since the previous tag, 6. writes `Casks/cdclint.rb` to `avison9/homebrew-tap`, -7. moves the major tag (`v0`, later `v1`) to this release, which is what +7. rewrites `Formula/cdclint.rb`'s `url` and `sha256` in the tap to this + tag's source tarball (the formula builds from source, the shape + homebrew/core wants; the rest of the file is by hand), +8. moves the major tag (`v0`, later `v1`) to this release, which is what `uses: avison9/cdclint@v0` resolves. -Check the run, then check the three places a user meets it: the Release -page, `brew install avison9/tap/cdclint` on a Mac or Linux box, and a -workflow using the action. +Check the run, then check the places a user meets it: the Release page, +`brew install avison9/tap/cdclint` (the formula, builds from source) and +`brew install --cask avison9/tap/cdclint` (the binary) on a Mac or Linux +box, and a workflow using the action. ## Trying the build without releasing