zuke.tools.homebrew
@zuke/homebrew 1.1.0: @zuke/homebrew — ship a prebuilt binary through a [Homebrew](https://brew.sh) tap from a Zuke build: BrewTasks wraps the brew CLI, and HomebrewTasks renders a formula, publishes it to the tap, verifies it installs, and declares the CI job that verifies it on macOS and Linux.
zuke on PyPI ↗ 22 symbols
Symbols
class BrewAuditSettings(BrewCommandSettings) Settings for brew audit. With no formulae named, brew audits every formula it can find.
-
formulae(*names: str) -> SelfFormulae to audit; repeatable.
-
strict() -> SelfRun the additional, stricter checks (
--strict). -
online() -> SelfRun the additional checks that need the network (
--online). -
new() -> SelfRun the checks for a formula new to Homebrew (
--new), which imply--strictand--online. -
formula() -> SelfTreat every name as a formula, not a cask (
--formula).
class BrewCommandSettings(BrewSettings) Base for a typed brew subcommand: the verb, then its own flags, then its operands — the order brew's own usage lines print. Anything added through the inherited .command(...)/.flag(...) escape hatches follows.
Operands are refused when they start with -. A formula or tap name never does, and brew would read one that did as an option — so --force passed as a "formula" would change what the command does rather than fail.
class BrewInfoSettings(BrewCommandSettings) Settings for brew info, which always runs with --json=v2 — the documented, machine-readable form — so the task can hand back a BrewInfo.
-
formulae(*names: str) -> SelfFormulae to describe; repeatable.
-
formula() -> SelfTreat every name as a formula, not a cask (
--formula). -
installed() -> SelfDescribe every installed formula (
--installed), instead of naming them.
class BrewInstallSettings(BrewCommandSettings) Settings for brew install. A formula is named by its name, its user/tap/name, or — where Homebrew still allows it — a local .rb path.
-
formulae(*names: str) -> SelfFormulae to install (required); repeatable.
-
formula() -> SelfTreat every name as a formula, not a cask (
--formula). -
build_from_source() -> SelfCompile from source even when a bottle exists (
--build-from-source). -
force() -> SelfInstall without checking for keg-only or unmigrated versions (
--force). -
verbose() -> SelfPrint the verification and post-install steps (
--verbose).
class BrewLivecheckSettings(BrewCommandSettings) Settings for brew livecheck, which looks for a newer upstream version.
-
formulae(*names: str) -> SelfFormulae to check; repeatable.
-
json() -> SelfPrint the result as JSON (
--json). -
newer_only() -> SelfReport only versions newer than the installed one (
--newer-only). -
formula() -> SelfCheck only formulae, not casks (
--formula).
class BrewRepositorySettings(BrewCommandSettings) Settings for brew --repository, which prints where Homebrew's repository is — or, given a tap, where that tap's directory is.
-
tap(name: str) -> SelfThe tap whose directory to print,
user/repo.
class BrewSettings(SubcommandSettings) Settings for a brew invocation.
class BrewStyleSettings(BrewCommandSettings) Settings for brew style, Homebrew's RuboCop check. With nothing named it checks Homebrew's own code and every tap.
-
targets(*values: str) -> SelfFiles, taps or formulae to check; repeatable.
-
fix() -> SelfCorrect what RuboCop can correct (
--fix).
class BrewTapNewSettings(BrewCommandSettings) Settings for brew tap-new, which generates a new, local tap.
-
name(tap: str) -> SelfThe tap to create (required),
user/repo. -
no_git() -> SelfDo not initialise a git repository for it (
--no-git). -
branch(name: str) -> SelfInitialise git on this branch, with its CI workflows (
--branch=).
class BrewTapSettings(BrewCommandSettings) Settings for brew tap, which adds a formula repository.
-
name(tap: str, url: str | None=None) -> SelfThe tap to add (required),
user/repo— brew clonesgithub.com/user/homebrew-repo— and optionally the URL to clone it from instead. -
force() -> SelfTap a core tap even under API mode (
--force).
class BrewTasks Typed task functions for the Homebrew brew CLI.
-
static async run(ctx: ServiceContext, configure: Callable[[BrewSettings], BrewSettings] | None=None) -> ExecResultRun any
brewcommand, built with.command(...)/.flag(...). -
static async install(ctx: ServiceContext, configure: Callable[[BrewInstallSettings], BrewInstallSettings]) -> ExecResultInstall formulae (
brew install). -
static async uninstall(ctx: ServiceContext, configure: Callable[[BrewUninstallSettings], BrewUninstallSettings]) -> ExecResultUninstall formulae (
brew uninstall). -
static async test(ctx: ServiceContext, configure: Callable[[BrewTestSettings], BrewTestSettings]) -> ExecResultRun installed formulae's
test doblocks (brew test). -
static async audit(ctx: ServiceContext, configure: Callable[[BrewAuditSettings], BrewAuditSettings] | None=None) -> ExecResultAudit formulae against Homebrew's rules (
brew audit). -
static async style(ctx: ServiceContext, configure: Callable[[BrewStyleSettings], BrewStyleSettings] | None=None) -> ExecResultCheck formulae against Homebrew's RuboCop style (
brew style). -
static async livecheck(ctx: ServiceContext, configure: Callable[[BrewLivecheckSettings], BrewLivecheckSettings] | None=None) -> ExecResultLook for newer upstream versions (
brew livecheck). -
static async tap(ctx: ServiceContext, configure: Callable[[BrewTapSettings], BrewTapSettings]) -> ExecResultAdd a tap (
brew tap). -
static async untap(ctx: ServiceContext, configure: Callable[[BrewUntapSettings], BrewUntapSettings]) -> ExecResultRemove taps (
brew untap). -
static async tap_new(ctx: ServiceContext, configure: Callable[[BrewTapNewSettings], BrewTapNewSettings]) -> ExecResultGenerate a new local tap (
brew tap-new). -
static async trust(ctx: ServiceContext, configure: Callable[[BrewTrustSettings], BrewTrustSettings]) -> ExecResultTrust a non-official tap's formulae, casks or commands (
brew trust). -
static async repository(ctx: ServiceContext, configure: Callable[[BrewRepositorySettings], BrewRepositorySettings] | None=None) -> objectThe directory of Homebrew's repository, or of a tap (
brew --repository [tap]), as a path with the trailing newline removed. -
static async info(ctx: ServiceContext, configure: Callable[[BrewInfoSettings], BrewInfoSettings]) -> objectDescribe formulae (
brew info --json=v2), parsed into a BrewInfo: names, versions and the installed versions.
class BrewTestSettings(BrewCommandSettings) Settings for brew test, which runs a formula's test do block.
-
formulae(*names: str) -> SelfInstalled formulae to test (required); repeatable.
-
force() -> SelfTest even when the formula is unlinked (
--force). -
keep_tmp() -> SelfKeep the temporary files the test created (
--keep-tmp). -
retry() -> SelfRetry once if the test fails (
--retry).
class BrewTrustSettings(BrewCommandSettings) Settings for brew trust, which lets Homebrew load a non-official tap's formulae, casks or commands. Current Homebrew refuses to load them from a tap it has not been told to trust.
-
targets(*names: str) -> SelfWhat to trust: taps, formulae, casks or commands by name; repeatable.
-
tap() -> SelfThe names are taps (
--tap). -
formula() -> SelfThe names are formulae (
--formula). -
cask() -> SelfThe names are casks (
--cask). -
external_command() -> SelfThe names are external commands (
--command).
class BrewUninstallSettings(BrewCommandSettings) Settings for brew uninstall.
-
formulae(*names: str) -> SelfFormulae to uninstall (required); repeatable.
-
formula() -> SelfTreat every name as a formula, not a cask (
--formula). -
force() -> SelfDelete every installed version (
--force). -
ignore_dependencies() -> SelfUninstall even when another formula depends on it (
--ignore-dependencies).
class BrewUntapSettings(BrewCommandSettings) Settings for brew untap, which removes taps.
-
taps(*names: str) -> SelfTaps to remove (required),
user/repo; repeatable. -
force() -> SelfUninstall the tap's formulae first, rather than refusing (
--force).
class FormulaBinarySettings(Settings) Settings for one prebuilt binary of a formula, rendered as on_<os> do on_<arch> do url "…" sha256 "…" end end.
`ts s.binary((b) => b.os("macos").arch("arm").url("https://…/app-aarch64-apple-darwin.tar.gz") .sha256("…") ) `
-
os(value: Literal['macos', 'linux']) -> SelfThe operating system the archive runs on (required).
-
arch(value: Literal['arm', 'intel']) -> SelfThe CPU family the archive runs on (required).
-
url(value: str) -> SelfWhere Homebrew downloads the archive (required; must be
https). -
sha256(value: str) -> SelfThe archive's SHA-256 (required; 64 lowercase hex digits).
class FormulaSettings(Settings) Settings for a formula that installs prebuilt binaries.
-
name(value: str) -> SelfThe formula name (required), e.g.
apporapp@2: a lowercase letter, then lowercase letters, digits,-,_,.,+or@. The Ruby class name is derived from it exactly as Homebrew does —app-clidefinesAppCli,app@2definesAppAT2. -
description(text: str) -> SelfThe one-line description (
desc, required), held tobrew audit's rules: at most 80 characters, starting with a capital letter, not with an article or the formula's name, and with no trailing period. -
homepage(url: str) -> SelfThe project's homepage (required; must be
https). -
version(value: str) -> SelfThe version, e.g.
1.2.3— set it only when Homebrew cannot read it from the archive URLs. Homebrew detects a formula's version from its URL, andbrew auditrejects aversionline that repeats what it detected ("version … is redundant with version scanned from URL"). A GitHub release asset such as…/releases/download/v1.2.3/app-aarch64-apple-darwin.tar.gzcarries it, so leave this unset there;expectVersion()in the test still works, against the detected version. Set it for a URL with no version in it, such as a…/releases/latest/download/…link or a content-addressed store. -
license(spdx: str) -> SelfThe SPDX license identifier, e.g.
MIT. -
binary(configure: Callable[[FormulaBinarySettings], FormulaBinarySettings]) -> SelfAdd a prebuilt archive for one OS and CPU family. Call once per platform; at least one is required, and each OS/arch pair at most once.
-
install(*files: str) -> SelfFiles from the archive to place in the formula's
bin(bin.install); at least one is required. Plain file names only — no directory part. -
caveats(text: str) -> SelfText Homebrew prints after installing (
def caveats). -
test(configure: Callable[[FormulaTestSettings], FormulaTestSettings]) -> SelfThe formula's
test doblock, whichbrew testruns. Without one,brew test(and soHomebrewTasks.verify) fails.
class FormulaTestSettings(Settings) Settings for the formula's test do block.
`ts s.test((t) => t.command("--version").expectVersion()) // test do // assert_match version.to_s, shell_output("#{bin}/app --version") // end `
Without an expectation the command only has to succeed, and is run with system and an argv — no shell at all.
-
binary(name: str) -> SelfWhich installed binary to run. Defaults to the first one the formula installs; it must be one of them.
-
command(*args: str) -> SelfThe arguments to run the binary with, e.g.
"--version". -
expect_version() -> SelfRequire the output to contain the formula's version.
-
expect_output(text: str) -> SelfRequire the output to contain
text.
class HomebrewPublishSettings(Settings) Settings for publishing a formula to a tap.
-
tap(value: str) -> SelfThe tap (required): its GitHub repository
owner/homebrew-x, or brew's short formowner/x, which names the same repository. -
formula(name: str, source: str) -> SelfThe formula to publish (required): its name, which becomes the file
Formula/<name>.rb, and its Ruby source — typically whatHomebrewTasks.formularendered. -
token(value: str) -> SelfThe token to write with — needs
contents: writeon the tap repository. Defaults toGITHUB_TOKEN, which only works when the tap is the repository the job runs in; a separate tap needs its own token. -
branch(name: str) -> SelfThe branch to commit on. Defaults to the tap's default branch.
-
message(text: str) -> SelfThe commit message. Defaults to
<name>: update formula. -
base_url(url: str) -> SelfThe API root, for GitHub Enterprise.
class HomebrewTasks Tasks for shipping a prebuilt binary through a Homebrew tap.
-
static async formula(ctx: ServiceContext, configure: Callable[[FormulaSettings], FormulaSettings]) -> objectThe Ruby source of a formula that installs prebuilt binaries — one archive per OS and CPU family. Pure: nothing is read or written.
-
static async publish(ctx: ServiceContext, configure: Callable[[HomebrewPublishSettings], HomebrewPublishSettings]) -> objectWrite
Formula/<name>.rbinto a tap repository on GitHub, or leave it alone — reportingunchanged— when the tap already holds exactly that source. -
static async verify(ctx: ServiceContext, configure: Callable[[HomebrewVerifySettings], HomebrewVerifySettings]) -> NoneInstall a formula file through a throwaway local tap, trusted first, run its test, then uninstall it and remove the tap — the cleanup runs whether or not the install and test succeeded.
-
static async verify_job(ctx: ServiceContext, configure: Callable[[HomebrewVerifyJobSettings], HomebrewVerifyJobSettings]) -> objectThe CI job that runs a verifying target across macOS and Linux runners, ready to list in
cicd({ invokes: [...] }).
class HomebrewVerifyJobSettings(Settings) Settings for the formula-verification CI job.
-
target(value: object) -> SelfThe target to run (required) — one that calls
HomebrewTasks.verify, or otherwise installs, tests and uninstalls the formula. -
runners(*labels: str) -> SelfThe runner labels to verify on, replacing the default
macos-latestandubuntu-latest— e.g."macos-15", "macos-15-intel", "ubuntu-latest"to cover both Mac CPU families. GitHub's ARM Linux runners (ubuntu-24.04-arm) ship without Homebrew, so they cannot verify a formula without installing it first.
class HomebrewVerifySettings(Settings) Settings for verifying a formula file.
-
formula_file(path: str) -> SelfThe formula's Ruby source on disk (required), e.g.
dist/app.rb. -
name(value: str) -> SelfThe formula's name (required) — the class the file defines is derived from it, and it is installed and tested under it.
-
tool_path(path: str) -> SelfThe
brewto run, when it is not onPATH— on a GitHub Linux runner Homebrew is installed but not onPATH:/home/linuxbrew/.linuxbrew/bin/brew.