Template repository for creating private homebrew taps with support for multiple download strategies.
This tap template supports downloading from various sources:
- GitHub - Private repositories and release assets
- GitLab - Private repositories and releases
- AWS S3 - Private buckets with IAM/credential authentication
- Generic URLs - With Bearer tokens, API keys, Basic auth, or custom headers
- Click "Use this template" to create a new repository from this template
- Name your new repository
homebrew-<your-tap-name> - Clone your new repository locally
- Update formulas in the
Formula/directory - Set required environment variables for authentication
# Create a new repository from this template
gh repo create homebrew-<your-tap-name> --template yourusername/homebrew-tap-template --private
# Clone your new repository
git clone https://github.com/yourusername/homebrew-<your-tap-name>
cd homebrew-<your-tap-name>
# Update formulas and set environment variables as neededAfter creating your repository:
- Update formulas in the
Formula/directory - Set required environment variables for authentication
- Test your formulas using the included test suite
Different download strategies require different environment variables:
Option 1: Personal Access Token
HOMEBREW_GITHUB_API_TOKEN- GitHub personal access token withreposcope
Option 2: GitHub CLI Authentication
- Authenticate with
gh auth login- the strategies will automatically use yourghcredentials - No environment variable needed if
ghis authenticated
Note: SSH keys alone are not sufficient for download strategies. The strategies need API access to download raw files and release assets, which requires either a personal access token or GitHub CLI authentication. SSH keys are only used for git operations (clone, push, pull).
Option 1: Personal Access Token
HOMEBREW_GITLAB_API_TOKENorGITLAB_PRIVATE_TOKEN- GitLab personal access token withapiscope
Option 2: GitLab CLI Authentication
- Authenticate with
glab auth login- the strategies will automatically use yourglabcredentials - Also supports
GITLAB_TOKENenvironment variable thatglabuses
AWS_ACCESS_KEY_ID- AWS access keyAWS_SECRET_ACCESS_KEY- AWS secret keyAWS_SESSION_TOKEN- (Optional) For temporary credentialsAWS_REGIONorAWS_DEFAULT_REGION- AWS region
HOMEBREW_BEARER_TOKEN- Bearer tokenHOMEBREW_API_KEY- API keyHOMEBREW_AUTH_USERandHOMEBREW_AUTH_PASSWORD- Basic auth credentialsHOMEBREW_AUTH_HEADERandHOMEBREW_AUTH_VALUE- Custom header auth
# Add the tap
brew tap yourusername/yourtap
# Install a formula
brew install yourusername/yourtap/yourformulaSee Formula/examples.rb for complete examples. Here's a simple GitHub private repo formula:
require_relative "../download_strategies/github_private_repo_download_strategy"
class MyTool < Formula
desc "My private tool"
homepage "https://github.com/myorg/mytool"
url "https://raw.githubusercontent.com/myorg/mytool/main/releases/mytool-v1.0.0.tar.gz",
using: GitHubPrivateRepoDownloadStrategy
version "1.0.0"
sha256 "abc123..."
def install
bin.install "mytool"
end
end- GitHubPrivateRepoDownloadStrategy - Raw files from private GitHub repos
- GitHubReleaseDownloadStrategy - GitHub release assets
- GitLabPrivateRepoDownloadStrategy - Raw files from private GitLab repos
- GitLabReleaseDownloadStrategy - GitLab release assets
- S3DownloadStrategy - AWS S3 private buckets
- S3PublicDownloadStrategy - AWS S3 public buckets
- AuthenticatedDownloadStrategy - Generic authenticated URLs
Test your formulas locally:
brew install --verbose --debug Formula/yourformula.rbThis tap includes a comprehensive test suite for validating all download strategies:
- Install the test utility:
brew install Formula/download-strategy-tester.rb- Run tests:
# Check your environment setup
download-strategy-tester --check-env
# Test all strategies
download-strategy-tester --all
# Test a specific strategy
download-strategy-tester --strategy github-raw- Copy the example config:
cp test/test-config.example.yml test/test-config.yml-
Edit
test/test-config.ymlwith your actual repository URLs -
Run tests with config:
download-strategy-tester --all --config test/test-config.ymlUse the included test runner script:
./test/run-tests.shThis will check prerequisites, validate environment variables, and run all tests.
- Never commit tokens or credentials to the repository
- Use environment variables for all authentication
- Consider using GitHub Secrets for CI/CD workflows
- Rotate tokens regularly
This template is released under the Unlicense (public domain).