Daniel Lyons' Notes

Distributing your own scripts via Homebrew

My Notes

Key Homebrew Terms

  • Formula: Package definition.
  • Tap: Git repository of formulae.
  • Cellar/Keg: Where formulae are installed.

High-Level Steps

  1. Create CLI & Tag Release: Code your CLI, push to GitHub, create a tagged release (e.g., v1.0.0).
  2. Create Homebrew Tap:
    • brew tap-new your_github_handle/homebrew-tap
    • Push scaffolded repo to GitHub: git remote add origin ... && git push
  3. Create Homebrew Formula:
    • GitHub provides tarballs for tags (e.g., https://github.com/user/cli/archive/refs/tags/v1.0.0.tar.gz).
    • brew create TARBALL_URL --tap your_handle/homebrew-tap --set-name your_cli --ruby
    • Customize & Debug: Edit the .rb formula file (e.g., depends_on "ruby@3" for Ruby CLIs). Use brew install --verbose and brew style.
    • Commit and push your formula to your tap repository.
  4. Automate Updates (Recommended):
    • Why: Automatically updates formula's URL and SHA256 for new CLI releases.
    • How: Use a GitHub Actions workflow in your CLI's repository.
    • Setup: Requires a GitHub PAT (with write access to tap repo) stored as a secret (HOMEBREW_TAP_TOKEN).

User Experience

  • Install:
    brew tap your_github_handle/tap
    brew install your_cool_cli
    
  • Update:
    brew update
    brew upgrade your_cool_cli
    
Distributing your own scripts via Homebrew
Interactive graph
On this page
My Notes
Key Homebrew Terms
High-Level Steps
User Experience