Distributing your own scripts via Homebrew
3 days ago
- #Developer Tools
- #Homebrew
- #CLI
- Homebrew is preferred for CLI installations over npm or Ruby gems.
- Homebrew terminology includes Formula (package definition), Tap (Git repository of formulae), Cask (GUI/binary manifest), Bottle (pre-built binary), Cellar (installation directory), and Keg (installed formula directory).
- To distribute a CLI via Homebrew: create a GitHub release, set up a Homebrew tap, create a Homebrew formula, and update it for each release.
- Users install CLI tools via `brew tap your_github_handle/tap` followed by `brew install your_cool_cli`.
- Creating a tap involves running `brew tap-new` and pushing to a GitHub repository.
- Formulas should reference versioned tarballs with checksums for reproducibility.
- Use `brew create` with flags like `--tap`, `--set-name`, and `--ruby` to generate a formula.
- Debug formulas using `brew install --verbose` and AI tools like ChatGPT.
- Automate formula updates via GitHub workflows with a personal access token (PAT).
- Once set up, publishing additional CLI tools becomes easier.