homebrew-formula-updater
Homebrew Formula Updater
Overview
This skill automates updating Homebrew formula files with the latest release information from GitHub repositories. It fetches the newest release tag, downloads release assets to compute SHA256 checksums, and updates the formula file with new URLs and hashes.
When to Use
- Updating a Homebrew formula after a new release is published
- Refreshing SHA256 checksums for release assets
- Bumping version numbers in formula files
- Syncing a homebrew-tap repository with upstream releases
When NOT to Use
- Formulas that build from source (no prebuilt release assets)
- Formulas with non-standard asset naming conventions (not
<repo>-<tag>-<platform>.tar.gz) - Releases hosted outside GitHub (e.g., GitLab, self-hosted)
- Formulas requiring manual patching or complex post-download processing
- Creating new formulas from scratch (this skill only updates existing formulas)
Workflow
Step 1: Identify the Formula and Repository
Determine the following from the user's request or by examining the formula file:
- Formula file path - The
.rbfile to update (e.g.,skulto.rb) - GitHub repository - The source repo in
owner/repoformat (e.g.,asteroid-belt/skulto)
The repository can often be inferred from the homepage or url fields in the formula.
Step 2: Run the Update Script
Execute the bundled Python script to fetch the latest release and update the formula:
python3 <skill-path>/scripts/update_formula.py <github_repo> <formula_file>
Example:
python3 scripts/update_formula.py asteroid-belt/skulto skulto.rb
The script will:
- Query the GitHub API for the latest release tag
- Download each platform-specific asset (darwin-amd64, darwin-arm64, linux-amd64, linux-arm64)
- Compute SHA256 checksums for each asset
- Update the formula file with new version, URLs, and checksums
- Create a backup of the original file (
.bakextension)
Step 3: Verify Changes
After the script completes:
- Review the updated formula file to ensure changes are correct
- Optionally run
brew audit --strict <formula>to validate the formula syntax - Test installation with
brew install --build-from-source <formula>
Dry Run Mode
To preview changes without modifying the formula:
python3 <skill-path>/scripts/update_formula.py <github_repo> <formula_file> --dry-run
Expected Formula Structure
The script expects formulas with platform-specific blocks like:
on_macos do
if Hardware::CPU.intel?
url "https://github.com/owner/repo/releases/download/vX.Y.Z/name-vX.Y.Z-darwin-amd64.tar.gz"
sha256 "..."
elsif Hardware::CPU.arm?
url "https://github.com/owner/repo/releases/download/vX.Y.Z/name-vX.Y.Z-darwin-arm64.tar.gz"
sha256 "..."
end
end
on_linux do
if Hardware::CPU.intel?
url "https://github.com/owner/repo/releases/download/vX.Y.Z/name-vX.Y.Z-linux-amd64.tar.gz"
sha256 "..."
elsif Hardware::CPU.arm?
url "https://github.com/owner/repo/releases/download/vX.Y.Z/name-vX.Y.Z-linux-arm64.tar.gz"
sha256 "..."
end
end
Asset Naming Convention
The script expects release assets named:
<repo-name>-<tag>-<platform>.tar.gz
Where <platform> is one of: darwin-amd64, darwin-arm64, linux-amd64, linux-arm64
Quality Checklist
Before completing the update:
- Verified the GitHub repository has the expected release asset naming convention
- Ran with
--dry-runfirst to preview changes - Reviewed the updated formula for correctness
- Backup file (
.bak) preserved in case rollback is needed - Optionally ran
brew audit --strict <formula>to validate syntax - Optionally tested with
brew install --build-from-source <formula>
Resources
scripts/
- update_formula.py - Python script that fetches the latest release and updates formula files (requires Python 3.8+)