Homebrew
Distribute your CLI tools via Homebrew with automatic formula generation and tap updates.
Prerequisites
- GitHub CLI installed and authenticated
- A Homebrew tap repository
- GitHub token with repo access
# Install GitHub CLIbrew install gh
# Authenticategh auth login
# Create a tap repository (if needed)gh repo create my-org/homebrew-tap --publicService Configuration
name: my-cliprovider: homebrewproject: my-orglicense: MIT
build: language: go version: "1.23" env_vars: CGO_ENABLED: "0"
homebrew: tap_url: https://github.com/my-org/homebrew-tap project_url: https://github.com/my-org/my-cli token_env: GH_TOKENRequired Fields
| Field | Description |
|---|---|
name | Binary and formula name |
project | GitHub organization/user |
homebrew.tap_url | URL to your Homebrew tap repository |
homebrew.project_url | URL to your project repository |
homebrew.token_env | Environment variable containing GitHub token |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
license | string | - | Software license (MIT, Apache-2.0, etc.) |
description | string | - | Package description |
Deployment Steps
The Homebrew recipe executes:
- build binaries — Cross-compile for macOS (Intel + Apple Silicon) and Linux
- create checksums — Generate SHA256 checksums
- create archives — Package binaries as
.tar.gz - update formula — Generate Homebrew formula
- push to tap — Commit and push to tap repository
Generated Formula
Pilum generates a formula like:
class MyCli < Formula desc "My awesome CLI tool" homepage "https://github.com/my-org/my-cli" version "1.0.0" license "MIT"
on_macos do if Hardware::CPU.arm? url "https://github.com/my-org/my-cli/releases/download/v1.0.0/my-cli-darwin-arm64.tar.gz" sha256 "abc123..." else url "https://github.com/my-org/my-cli/releases/download/v1.0.0/my-cli-darwin-amd64.tar.gz" sha256 "def456..." end end
on_linux do url "https://github.com/my-org/my-cli/releases/download/v1.0.0/my-cli-linux-amd64.tar.gz" sha256 "ghi789..." end
def install bin.install "my-cli" end
test do system "#{bin}/my-cli", "--version" endendGitHub Token
Set up a token with repo scope:
- Go to GitHub → Settings → Developer settings → Personal access tokens
- Generate a token with
reposcope - Export it:
export GH_TOKEN="ghp_xxxxx"Or add to your CI environment variables.
Example Commands
# Build and releasepilum deploy --tag=v1.0.0
# Build binaries onlypilum build --tag=v1.0.0
# Preview commandspilum dry-run --tag=v1.0.0Multi-Platform Builds
Pilum automatically builds for:
| Platform | Architecture | File |
|---|---|---|
| macOS | Intel (amd64) | my-cli-darwin-amd64.tar.gz |
| macOS | Apple Silicon (arm64) | my-cli-darwin-arm64.tar.gz |
| Linux | x86_64 (amd64) | my-cli-linux-amd64.tar.gz |
Troubleshooting
Formula Push Fails
Step 5: push to tap my-cli ✗ - authentication requiredEnsure GH_TOKEN is set:
export GH_TOKEN="ghp_xxxxx"Checksum Mismatch
If users report checksum errors after updating:
- Verify the release assets match the formula
- Re-run
pilum deploy --tag=vX.Y.Zto regenerate
Binary Not Found
Ensure the build produces the expected binary:
ls dist/# Should show: my-cli-darwin-amd64, my-cli-darwin-arm64, my-cli-linux-amd64Installation by Users
Once published, users install with:
brew tap my-org/tapbrew install my-cliOr in one command:
brew install my-org/tap/my-cliNext Steps
- Service Configuration — Full reference
- Build Configuration — Cross-compilation settings
- Troubleshooting — Common issues