|
| 1 | +# VTCode Homebrew Distribution Setup Guide |
| 2 | + |
| 3 | +This guide will help you set up Homebrew distribution for VTCode on macOS. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. **GitHub Repository**: You need a GitHub repository for your Homebrew tap |
| 8 | +2. **GitHub Release**: You need to create a GitHub release with pre-built binaries |
| 9 | +3. **SHA256 Hashes**: You need to calculate SHA256 hashes for your binaries |
| 10 | + |
| 11 | +## Step 1: Create Homebrew Tap Repository |
| 12 | + |
| 13 | +### Option A: Create a new tap repository |
| 14 | + |
| 15 | +1. Create a new GitHub repository named `homebrew-tap` (or similar) |
| 16 | +2. Clone it locally: |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/YOUR_USERNAME/homebrew-tap.git |
| 20 | +cd homebrew-tap |
| 21 | +``` |
| 22 | + |
| 23 | +### Option B: Use existing tap repository |
| 24 | + |
| 25 | +If you already have a tap repository, use that instead. |
| 26 | + |
| 27 | +## Step 2: Create the Formula |
| 28 | + |
| 29 | +Create a file named `vtcode.rb` in your tap repository: |
| 30 | + |
| 31 | +```ruby |
| 32 | +class Vtcode < Formula |
| 33 | + desc "A Rust-based terminal coding agent with modular architecture" |
| 34 | + homepage "https://github.com/vinhnx/vtcode" |
| 35 | + version "0.8.1" |
| 36 | + |
| 37 | + on_macos do |
| 38 | + if Hardware::CPU.arm? |
| 39 | + url "https://github.com/vinhnx/vtcode/releases/download/v#{version}/vtcode-v#{version}-aarch64-apple-darwin.tar.gz" |
| 40 | + sha256 "CALCULATE_THIS_SHA256_HASH" |
| 41 | + else |
| 42 | + url "https://github.com/vinhnx/vtcode/releases/download/v#{version}/vtcode-v#{version}-x86_64-apple-darwin.tar.gz" |
| 43 | + sha256 "CALCULATE_THIS_SHA256_HASH" |
| 44 | + end |
| 45 | + end |
| 46 | + |
| 47 | + def install |
| 48 | + bin.install "vtcode" |
| 49 | + end |
| 50 | + |
| 51 | + test do |
| 52 | + system "#{bin}/vtcode", "--version" |
| 53 | + end |
| 54 | +end |
| 55 | +``` |
| 56 | + |
| 57 | +## Step 3: Calculate SHA256 Hashes |
| 58 | + |
| 59 | +After creating a GitHub release with your binaries, calculate the SHA256 hashes: |
| 60 | + |
| 61 | +### For Intel Mac: |
| 62 | + |
| 63 | +```bash |
| 64 | +# Download the Intel binary |
| 65 | +curl -L -o vtcode-intel.tar.gz https://github.com/vinhnx/vtcode/releases/download/v0.8.1/vtcode-v0.8.1-x86_64-apple-darwin.tar.gz |
| 66 | + |
| 67 | +# Calculate SHA256 |
| 68 | +shasum -a 256 vtcode-intel.tar.gz |
| 69 | +``` |
| 70 | + |
| 71 | +### For Apple Silicon Mac: |
| 72 | + |
| 73 | +```bash |
| 74 | +# Download the ARM binary |
| 75 | +curl -L -o vtcode-arm.tar.gz https://github.com/vinhnx/vtcode/releases/download/v0.8.1/vtcode-v0.8.1-aarch64-apple-darwin.tar.gz |
| 76 | + |
| 77 | +# Calculate SHA256 |
| 78 | +shasum -a 256 vtcode-arm.tar.gz |
| 79 | +``` |
| 80 | + |
| 81 | +## Step 4: Update the Formula |
| 82 | + |
| 83 | +Replace `CALCULATE_THIS_SHA256_HASH` with the actual SHA256 hashes in your `vtcode.rb` file. |
| 84 | + |
| 85 | +## Step 5: Commit and Push |
| 86 | + |
| 87 | +```bash |
| 88 | +git add vtcode.rb |
| 89 | +git commit -m "Add vtcode formula v0.8.1" |
| 90 | +git push origin main |
| 91 | +``` |
| 92 | + |
| 93 | +## Step 6: Test the Formula |
| 94 | + |
| 95 | +Test your formula locally: |
| 96 | + |
| 97 | +```bash |
| 98 | +# Test the formula |
| 99 | +brew install --build-from-source vtcode.rb |
| 100 | + |
| 101 | +# Verify installation |
| 102 | +vtcode --version |
| 103 | + |
| 104 | +# Uninstall for testing |
| 105 | +brew uninstall vtcode |
| 106 | +``` |
| 107 | + |
| 108 | +## Step 7: Update Release Script |
| 109 | + |
| 110 | +Update your release script to automatically update the Homebrew formula. Here's how: |
| 111 | + |
| 112 | +### Option A: Manual Update (Current) |
| 113 | + |
| 114 | +The current release script shows instructions for manual update. |
| 115 | + |
| 116 | +### Option B: Automated Update |
| 117 | + |
| 118 | +To automate Homebrew formula updates, you can: |
| 119 | + |
| 120 | +1. **Use GitHub Actions** to automatically update the formula when a new release is created |
| 121 | +2. **Use a script** to update the formula as part of your release process |
| 122 | + |
| 123 | +Example automated update script: |
| 124 | + |
| 125 | +```bash |
| 126 | +#!/bin/bash |
| 127 | + |
| 128 | +# Update Homebrew formula |
| 129 | +update_homebrew_formula() { |
| 130 | + local version=$1 |
| 131 | + local tap_repo="YOUR_USERNAME/homebrew-tap" |
| 132 | + local formula_path="vtcode.rb" |
| 133 | + |
| 134 | + # Clone or update tap repository |
| 135 | + if [ ! -d "homebrew-tap" ]; then |
| 136 | + git clone "https://github.com/$tap_repo.git" homebrew-tap |
| 137 | + fi |
| 138 | + |
| 139 | + cd homebrew-tap |
| 140 | + |
| 141 | + # Update formula with new version and SHA256 |
| 142 | + # This would require calculating SHA256 hashes automatically |
| 143 | + # Implementation depends on your CI/CD setup |
| 144 | + |
| 145 | + cd .. |
| 146 | +} |
| 147 | +``` |
| 148 | + |
| 149 | +## Usage |
| 150 | + |
| 151 | +Once your tap is set up, users can install VTCode with: |
| 152 | + |
| 153 | +```bash |
| 154 | +# Add your tap |
| 155 | +brew tap YOUR_USERNAME/homebrew-tap |
| 156 | + |
| 157 | +# Install VTCode |
| 158 | +brew install YOUR_USERNAME/homebrew-tap/vtcode |
| 159 | +``` |
| 160 | + |
| 161 | +Or if you name your tap `homebrew-tap`: |
| 162 | + |
| 163 | +```bash |
| 164 | +brew tap YOUR_USERNAME/homebrew-tap |
| 165 | +brew install vtcode |
| 166 | +``` |
| 167 | + |
| 168 | +## Maintenance |
| 169 | + |
| 170 | +### Updating the Formula |
| 171 | + |
| 172 | +When you release a new version: |
| 173 | + |
| 174 | +1. Create a new GitHub release with binaries |
| 175 | +2. Calculate new SHA256 hashes |
| 176 | +3. Update the `vtcode.rb` file in your tap repository |
| 177 | +4. Commit and push the changes |
| 178 | + |
| 179 | +### Version Management |
| 180 | + |
| 181 | +Keep your formula version in sync with your main project version. The formula should always point to the latest stable release. |
| 182 | + |
| 183 | +## Troubleshooting |
| 184 | + |
| 185 | +### Common Issues |
| 186 | + |
| 187 | +1. **SHA256 mismatch**: Make sure you're using the correct SHA256 hash for the binary |
| 188 | +2. **Architecture issues**: Ensure you have binaries for both Intel and Apple Silicon Macs |
| 189 | +3. **Permission issues**: Make sure your tap repository is public or users have access |
| 190 | + |
| 191 | +### Testing |
| 192 | + |
| 193 | +Always test your formula before publishing: |
| 194 | + |
| 195 | +```bash |
| 196 | +# Test installation |
| 197 | +brew install --build-from-source vtcode.rb |
| 198 | + |
| 199 | +# Test functionality |
| 200 | +vtcode --version |
| 201 | + |
| 202 | +# Clean up |
| 203 | +brew uninstall vtcode |
| 204 | +``` |
| 205 | + |
| 206 | +## Integration with Release Script |
| 207 | + |
| 208 | +To integrate with your release script, add this function: |
| 209 | + |
| 210 | +```bash |
| 211 | +# Function to update Homebrew formula |
| 212 | +update_homebrew_formula() { |
| 213 | + local version=$1 |
| 214 | + local tap_repo="YOUR_USERNAME/homebrew-tap" |
| 215 | + |
| 216 | + print_info "Updating Homebrew formula to version $version" |
| 217 | + |
| 218 | + # Calculate SHA256 hashes for new binaries |
| 219 | + # This would need to be implemented based on your release process |
| 220 | + |
| 221 | + print_info "Homebrew formula update instructions:" |
| 222 | + print_info "1. Update version in $tap_repo/vtcode.rb to $version" |
| 223 | + print_info "2. Update SHA256 hashes for new binaries" |
| 224 | + print_info "3. Commit and push changes to $tap_repo" |
| 225 | + print_info "4. Users can then run: brew install $tap_repo/vtcode" |
| 226 | +} |
| 227 | +``` |
| 228 | + |
| 229 | +This setup provides a complete Homebrew distribution system for VTCode that integrates with your existing release process. |
0 commit comments