|
| 1 | +# Package Manager Setup Guide |
| 2 | + |
| 3 | +This guide explains how to set up the automated package publishing for Homebrew and Chocolatey. |
| 4 | + |
| 5 | +## 🍺 Homebrew Setup |
| 6 | + |
| 7 | +### 1. Create Homebrew Tap Repository |
| 8 | + |
| 9 | +First, you need to create a separate repository for the Homebrew tap: |
| 10 | + |
| 11 | +```bash |
| 12 | +# Create a new repository named 'homebrew-cli' |
| 13 | +# This should be done through GitHub UI or API |
| 14 | +# Repository should be: codebase-interface/homebrew-cli |
| 15 | +``` |
| 16 | + |
| 17 | +The repository structure will look like: |
| 18 | +``` |
| 19 | +homebrew-cli/ |
| 20 | +└── Formula/ |
| 21 | + └── codebase-interface.rb |
| 22 | +``` |
| 23 | + |
| 24 | +### 2. Set Up GitHub Token |
| 25 | + |
| 26 | +Create a GitHub token with repository access: |
| 27 | + |
| 28 | +1. Go to GitHub Settings → Developer settings → Personal access tokens |
| 29 | +2. Generate a new token (classic) with `repo` permissions |
| 30 | +3. Add it as a repository secret named `HOMEBREW_TAP_GITHUB_TOKEN` |
| 31 | + |
| 32 | +### 3. How It Works |
| 33 | + |
| 34 | +When you create a release: |
| 35 | + |
| 36 | +1. **GoReleaser** automatically creates a Homebrew formula |
| 37 | +2. **Formula** gets pushed to `codebase-interface/homebrew-cli` |
| 38 | +3. **Users** can then install with: |
| 39 | + ```bash |
| 40 | + brew tap codebase-interface/cli |
| 41 | + brew install codebase-interface |
| 42 | + ``` |
| 43 | + |
| 44 | +The formula will be generated automatically and look like: |
| 45 | +```ruby |
| 46 | +class CodebaseInterface < Formula |
| 47 | + desc "A CLI tool for validating codebase structure and development standards" |
| 48 | + homepage "https://github.com/codebase-interface/cli" |
| 49 | + url "https://github.com/codebase-interface/cli/releases/download/v1.0.0/codebase-interface-Darwin-x86_64.tar.gz" |
| 50 | + sha256 "..." |
| 51 | + license "MIT" |
| 52 | + |
| 53 | + def install |
| 54 | + bin.install "codebase-interface" |
| 55 | + bin.install_symlink bin/"codebase-interface" => "cbi" |
| 56 | + end |
| 57 | + |
| 58 | + test do |
| 59 | + system "#{bin}/codebase-interface", "version" |
| 60 | + system "#{bin}/cbi", "version" |
| 61 | + end |
| 62 | +end |
| 63 | +``` |
| 64 | + |
| 65 | +## 🍫 Chocolatey Setup |
| 66 | + |
| 67 | +### 1. Create Chocolatey Account |
| 68 | + |
| 69 | +1. Create account at [chocolatey.org](https://chocolatey.org/) |
| 70 | +2. Get your API key from your account profile |
| 71 | +3. Add it as a repository secret named `CHOCOLATEY_API_KEY` |
| 72 | + |
| 73 | +### 2. How It Works |
| 74 | + |
| 75 | +When you create a release: |
| 76 | + |
| 77 | +1. **GoReleaser** creates a Chocolatey package (.nupkg) |
| 78 | +2. **Package** gets automatically uploaded to Chocolatey repository |
| 79 | +3. **Users** can then install with: |
| 80 | + ```powershell |
| 81 | + choco install codebase-interface |
| 82 | + ``` |
| 83 | + |
| 84 | +The package will include: |
| 85 | +- Windows executable |
| 86 | +- PowerShell install/uninstall scripts |
| 87 | +- Automatic PATH configuration |
| 88 | +- Both `codebase-interface.exe` and `cbi.exe` commands |
| 89 | + |
| 90 | +## 🔧 Required Repository Secrets |
| 91 | + |
| 92 | +Add these secrets to your GitHub repository: |
| 93 | + |
| 94 | +```bash |
| 95 | +# For Homebrew tap publishing |
| 96 | +HOMEBREW_TAP_GITHUB_TOKEN=github_pat_... |
| 97 | + |
| 98 | +# For Chocolatey package publishing |
| 99 | +CHOCOLATEY_API_KEY=... |
| 100 | + |
| 101 | +# Already configured for GitHub releases |
| 102 | +GITHUB_TOKEN=... (automatic) |
| 103 | +``` |
| 104 | + |
| 105 | +## 🎯 Testing Package Managers |
| 106 | + |
| 107 | +### Test Homebrew Locally |
| 108 | + |
| 109 | +```bash |
| 110 | +# Install from your tap |
| 111 | +brew tap codebase-interface/cli |
| 112 | +brew install codebase-interface |
| 113 | + |
| 114 | +# Verify installation |
| 115 | +codebase-interface version |
| 116 | +cbi version |
| 117 | + |
| 118 | +# Test upgrade path |
| 119 | +brew upgrade codebase-interface |
| 120 | +``` |
| 121 | + |
| 122 | +### Test Chocolatey Locally |
| 123 | + |
| 124 | +```powershell |
| 125 | +# Install from Chocolatey |
| 126 | +choco install codebase-interface |
| 127 | +
|
| 128 | +# Verify installation |
| 129 | +codebase-interface version |
| 130 | +cbi version |
| 131 | +
|
| 132 | +# Test upgrade path |
| 133 | +choco upgrade codebase-interface |
| 134 | +``` |
| 135 | + |
| 136 | +## 📋 Release Checklist |
| 137 | + |
| 138 | +Before releasing with package manager support: |
| 139 | + |
| 140 | +- [ ] Create `codebase-interface/homebrew-cli` repository |
| 141 | +- [ ] Add `HOMEBREW_TAP_GITHUB_TOKEN` secret |
| 142 | +- [ ] Add `CHOCOLATEY_API_KEY` secret |
| 143 | +- [ ] Test GoReleaser configuration locally: |
| 144 | + ```bash |
| 145 | + goreleaser check |
| 146 | + goreleaser release --snapshot --clean |
| 147 | + ``` |
| 148 | +- [ ] Create a test release with a pre-release tag |
| 149 | +- [ ] Verify packages are published correctly |
| 150 | + |
| 151 | +## 🚀 First Release |
| 152 | + |
| 153 | +For your first release with package managers: |
| 154 | + |
| 155 | +1. **Create the required repositories and secrets** |
| 156 | +2. **Tag your release:** |
| 157 | + ```bash |
| 158 | + git tag v1.0.0 |
| 159 | + git push --tags |
| 160 | + ``` |
| 161 | +3. **Monitor the GitHub Action** to ensure all steps complete |
| 162 | +4. **Test installation** from both package managers |
| 163 | +5. **Update documentation** with installation instructions |
| 164 | + |
| 165 | +The release process will: |
| 166 | +- ✅ Build binaries for all platforms |
| 167 | +- ✅ Create GitHub release with assets |
| 168 | +- ✅ Publish Docker images to GHCR |
| 169 | +- ✅ Create Homebrew formula in tap repository |
| 170 | +- ✅ Publish Chocolatey package to chocolatey.org |
| 171 | + |
| 172 | +After the first successful release, users will be able to install your CLI using standard package managers! |
0 commit comments