This repository provides a template for creating and maintaining a Homebrew tap that automatically updates when new releases are published on GitHub. It's particularly useful for closed-source applications distributed through GitHub releases.
- Create a new GitHub repository named
homebrew-yourtap
- Clone this template repository and push to your new repo:
git clone https://github.com/your-username/homebrew-yourtap cd homebrew-yourtap
-
Copy the template formula:
cp Formula/application.rb Formula/your-app-name.rb
-
Edit
Formula/your-app-name.rb
and replace all placeholders:{REPLACE_WITH_FORMULA_NAME}
- Your formula class name (CamelCase){REPLACE_WITH_DESCRIPTION}
- Application description{REPLACE_WITH_GITHUB_REPO}
- GitHub repository URL{REPLACE_WITH_VERSION}
- Initial version{REPLACE_WITH_ARM64_URL}
- ARM64 download URL{REPLACE_WITH_X86_64_URL}
- x86_64 download URL- Other placeholders as needed
- Edit
.github/workflows/update-clouddrive.yml
and replace all placeholders:{REPLACE_WITH_APP_NAME}
- Your application name{REPLACE_WITH_CRON_SCHEDULE}
- Update check schedule{REPLACE_WITH_GITHUB_OWNER}
- Source repository owner{REPLACE_WITH_GITHUB_REPO}
- Source repository name{REPLACE_WITH_GITHUB_USERNAME}
- Your GitHub username{REPLACE_WITH_TAP_REPO}
- Your tap repository name{REPLACE_WITH_GIT_EMAIL}
- Your Git email{REPLACE_WITH_GIT_USERNAME}
- Your Git username- URL patterns according to your release asset naming convention
-
Generate a GitHub Personal Access Token:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate a new token with
repo
scope - Copy the token
-
Add the token to your repository:
- Go to your repository Settings → Secrets and variables → Actions
- Create a new secret named
GH_TOKEN
- Paste your token as the value
-
Add your tap to Homebrew:
brew tap your-username/yourtap
-
Install your application:
brew install your-app-name
-
Verify the installation:
your-app-name --version
- The workflow runs on a schedule (defined by your cron expression)
- It checks the source repository for new releases
- When a new release is found:
- Downloads the new release assets
- Calculates SHA256 checksums
- Updates the formula file
- Commits and pushes changes
- Edit
Formula/your-app-name.rb
to add dependencies - Modify installation steps
- Add custom caveats
- Configure service management
- Adjust the update check frequency
- Modify the release asset naming pattern
- Add additional validation steps
- Customize commit messages
-
GitHub API Rate Limiting
- Ensure your GH_TOKEN is properly configured
- Check token permissions
-
Formula Update Failures
- Verify URL patterns match your release assets
- Check SHA256 calculation logic
- Ensure sed patterns match your formula structure
-
Installation Issues
- Verify formula class name matches file name
- Check all dependencies are properly specified
- Ensure binary permissions are correct
This template is available as open source under the terms of the MIT License.