Skip to content

Commit 9782129

Browse files
feat(homebrew): add Homebrew Formula for claude-switch
Formula/claude-switch.rb: - Homebrew formula for macOS/Linux installation - URL points to GitHub archive tarball - SHA256 checksum for security - Dependencies: netcat (required), ollama & node (optional) - Installs to /usr/local/bin Formula/README.md: - Maintainer guide for formula updates - Release process documentation Usage: brew tap FlorianBruniaux/tap brew install claude-switch Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 14b8d8e commit 9782129

2 files changed

Lines changed: 231 additions & 0 deletions

File tree

Formula/README.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# Homebrew Formula
2+
3+
Cette Formula permet l'installation de `claude-switch` via Homebrew.
4+
5+
## Pour les Utilisateurs
6+
7+
**Installation** :
8+
```bash
9+
brew tap FlorianBruniaux/tap
10+
brew install claude-switch
11+
eval "$(claude-switch --shell-config)"
12+
```
13+
14+
**Mise à jour** :
15+
```bash
16+
brew update
17+
brew upgrade claude-switch
18+
```
19+
20+
**Désinstallation** :
21+
```bash
22+
brew uninstall claude-switch
23+
brew untap FlorianBruniaux/tap
24+
```
25+
26+
## Pour les Mainteneurs
27+
28+
### Structure du Tap
29+
30+
Le Homebrew tap se trouve dans un repo séparé : `FlorianBruniaux/homebrew-tap`
31+
32+
```
33+
homebrew-tap/
34+
├── Formula/
35+
│ └── claude-switch.rb # Copié depuis cc-copilot-bridge/Formula/
36+
└── README.md
37+
```
38+
39+
### Workflow de Release
40+
41+
**Automatique via GitHub Actions** :
42+
43+
1. **Tag push** déclenche `.github/workflows/build-packages.yml`
44+
2. GitHub Actions :
45+
- Compute SHA256 du tarball
46+
- Build packages (.deb, .rpm)
47+
- Update `Formula/claude-switch.rb` avec SHA256
48+
- Create GitHub Release
49+
- **Commit Formula update** dans `cc-copilot-bridge`
50+
51+
3. **Copie manuelle vers tap** :
52+
```bash
53+
cd ~/Sites/perso/homebrew-tap
54+
cp ../cc-copilot-bridge/Formula/claude-switch.rb Formula/
55+
git add Formula/claude-switch.rb
56+
git commit -m "Update claude-switch to v1.5.3"
57+
git push
58+
```
59+
60+
### Tester la Formula Localement
61+
62+
**Avant de pusher vers tap** :
63+
64+
```bash
65+
# 1. Build from local formula
66+
brew install --build-from-source ./Formula/claude-switch.rb
67+
68+
# 2. Vérifier
69+
claude-switch --version
70+
eval "$(claude-switch --shell-config)"
71+
ccd --help
72+
73+
# 3. Tester les dépendances
74+
which nc # Netcat doit être installé
75+
76+
# 4. Désinstaller
77+
brew uninstall claude-switch
78+
```
79+
80+
### Valider la Formula
81+
82+
```bash
83+
# Linter Homebrew
84+
brew audit --strict ./Formula/claude-switch.rb
85+
86+
# Style check
87+
brew style ./Formula/claude-switch.rb
88+
89+
# Test installation
90+
brew install --build-from-source ./Formula/claude-switch.rb
91+
brew test claude-switch
92+
```
93+
94+
### Dépendances
95+
96+
**Requises** :
97+
- `netcat` : Pour health checks de provider
98+
99+
**Optionnelles** :
100+
- `ollama` : Pour provider Ollama local
101+
- `node` : Pour copilot-api (GitHub Copilot provider)
102+
103+
### SHA256 Checksum
104+
105+
**Pourquoi ?**
106+
- Sécurité : Vérifie l'intégrité du téléchargement
107+
- Prévient les attaques man-in-the-middle
108+
109+
**Comment calculer ?**
110+
111+
GitHub Actions calcule automatiquement :
112+
```bash
113+
git archive --format=tar.gz --prefix=cc-copilot-bridge-1.5.2/ HEAD > release.tar.gz
114+
sha256sum release.tar.gz | awk '{print $1}'
115+
```
116+
117+
**Manuellement** :
118+
```bash
119+
wget https://github.com/FlorianBruniaux/cc-copilot-bridge/archive/refs/tags/v1.5.2.tar.gz
120+
sha256sum v1.5.2.tar.gz
121+
```
122+
123+
**Si mismatch** :
124+
```bash
125+
# Recalculer
126+
wget https://github.com/FlorianBruniaux/cc-copilot-bridge/archive/refs/tags/v1.5.2.tar.gz
127+
NEW_SHA=$(sha256sum v1.5.2.tar.gz | awk '{print $1}')
128+
129+
# Update Formula
130+
sed -i "s/sha256 \".*\"/sha256 \"${NEW_SHA}\"/" Formula/claude-switch.rb
131+
132+
# Commit et push
133+
git add Formula/claude-switch.rb
134+
git commit -m "Fix SHA256 checksum for v1.5.2"
135+
git push
136+
```
137+
138+
### Troubleshooting
139+
140+
#### "SHA256 mismatch"
141+
142+
**Cause** : GitHub tarball change entre calcul et download
143+
144+
**Solution** : Recalculer SHA256 (voir ci-dessus)
145+
146+
#### "Could not resolve dependencies"
147+
148+
**Cause** : Netcat pas trouvé
149+
150+
**Solution** :
151+
```bash
152+
brew install netcat
153+
```
154+
155+
#### "File already exists"
156+
157+
**Cause** : Installation précédente
158+
159+
**Solution** :
160+
```bash
161+
brew uninstall claude-switch
162+
brew install claude-switch
163+
```
164+
165+
### Ressources
166+
167+
**Documentation officielle Homebrew** :
168+
- [Formula Cookbook](https://docs.brew.sh/Formula-Cookbook)
169+
- [Adding Software to Homebrew](https://docs.brew.sh/Adding-Software-to-Homebrew)
170+
- [Homebrew Terminology](https://docs.brew.sh/Formula-Cookbook#homebrew-terminology)
171+
172+
**Guides du projet** :
173+
- [PACKAGE-MANAGERS.md](../docs/PACKAGE-MANAGERS.md) : Guide utilisateur
174+
- [PACKAGE-MANAGERS-EXPLAINED.md](../docs/PACKAGE-MANAGERS-EXPLAINED.md) : Détails techniques
175+
- [RELEASE-PROCESS.md](../docs/RELEASE-PROCESS.md) : Process de release
176+
177+
### Exemples de Formulas
178+
179+
Pour inspiration, voir :
180+
- [fzf](https://github.com/Homebrew/homebrew-core/blob/master/Formula/f/fzf.rb)
181+
- [ripgrep](https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/ripgrep.rb)
182+
- [bat](https://github.com/Homebrew/homebrew-core/blob/master/Formula/b/bat.rb)

Formula/cc-copilot-bridge.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
class CcCopilotBridge < Formula
2+
desc "Multi-provider switcher for Claude Code CLI"
3+
homepage "https://github.com/FlorianBruniaux/cc-copilot-bridge"
4+
url "https://github.com/FlorianBruniaux/cc-copilot-bridge/releases/download/v1.5.2/cc-copilot-bridge-1.5.2.tar.gz"
5+
sha256 "PLACEHOLDER_SHA256" # Will be computed by GitHub Actions
6+
license "MIT"
7+
version "1.5.2"
8+
9+
depends_on "netcat"
10+
11+
# Optional dependencies
12+
depends_on "ollama" => :optional
13+
depends_on "node" => :optional # For copilot-api
14+
15+
def install
16+
bin.install "claude-switch"
17+
18+
# Create log directory
19+
(var/"log/claude-switch").mkpath
20+
21+
# Install docs
22+
doc.install "README.md" if File.exist?("README.md")
23+
doc.install "QUICKSTART.md" if File.exist?("QUICKSTART.md")
24+
doc.install Dir["docs/*"] if Dir.exist?("docs")
25+
end
26+
27+
def caveats
28+
<<~EOS
29+
To enable shell aliases, add to your ~/.zshrc or ~/.bashrc:
30+
31+
eval "$(claude-switch --shell-config)"
32+
33+
Or test it first:
34+
35+
source <(claude-switch --shell-config)
36+
37+
For more integration options:
38+
https://github.com/FlorianBruniaux/cc-copilot-bridge/blob/main/docs/INSTALL-OPTIONS.md
39+
40+
Logs are stored in:
41+
#{var}/log/claude-switch/claude-switch.log
42+
EOS
43+
end
44+
45+
test do
46+
assert_match(/claude-switch v\d+\.\d+/, shell_output("#{bin}/claude-switch --version"))
47+
assert_match "alias ccd=", shell_output("#{bin}/claude-switch --shell-config")
48+
end
49+
end

0 commit comments

Comments
 (0)