Skip to content

Commit 0ab594c

Browse files
feat: automate homebrew tap updates via GitHub Actions
- Add automated homebrew formula updates to release workflow - Download release assets and calculate SHA256 checksums - Automatically update homebrew-tap repository - Add documentation for GitHub Actions setup - Update formula with markers for automated SHA256 replacement This eliminates manual steps when creating new releases. Requires HOMEBREW_TAP_TOKEN secret to be configured.
1 parent f155276 commit 0ab594c

File tree

3 files changed

+142
-2
lines changed

3 files changed

+142
-2
lines changed

.github/workflows/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# GitHub Actions Setup
2+
3+
## Release Workflow
4+
5+
Der Release-Workflow wird automatisch ausgelöst, wenn ein neuer Tag (z.B. `v1.2.0`) gepusht wird.
6+
7+
### Automatisierte Schritte:
8+
9+
1. **Build für beide Architekturen** (ARM64 und x86_64)
10+
2. **Erstellen von Release-Archives** (.tar.gz)
11+
3. **Berechnen der SHA256-Checksums**
12+
4. **Upload der Release-Assets zu GitHub**
13+
5. **Automatisches Update der Homebrew Formula**
14+
15+
### Erforderliches Secret einrichten:
16+
17+
Um die Homebrew Formula automatisch zu aktualisieren, muss ein GitHub Token erstellt werden:
18+
19+
#### 1. Personal Access Token erstellen:
20+
21+
1. Gehe zu: https://github.com/settings/tokens
22+
2. Klicke auf "Generate new token" → "Generate new token (classic)"
23+
3. Name: `Homebrew Tap Update`
24+
4. Setze folgende Berechtigungen:
25+
-`repo` (Full control of private repositories)
26+
5. Klicke auf "Generate token"
27+
6. **Kopiere den Token** (wird nur einmal angezeigt!)
28+
29+
#### 2. Secret im tide Repository hinzufügen:
30+
31+
1. Gehe zu: https://github.com/BreathCodeFlow/tide/settings/secrets/actions
32+
2. Klicke auf "New repository secret"
33+
3. Name: `HOMEBREW_TAP_TOKEN`
34+
4. Value: [Den kopierten Token einfügen]
35+
5. Klicke auf "Add secret"
36+
37+
### Neues Release erstellen:
38+
39+
```bash
40+
# 1. Version in Cargo.toml aktualisieren
41+
# 2. Änderungen committen
42+
git add Cargo.toml
43+
git commit -m "chore: bump version to 1.3.0"
44+
45+
# 3. Tag erstellen
46+
git tag -a v1.3.0 -m "Release v1.3.0
47+
48+
- Feature 1
49+
- Feature 2
50+
- Fix 1
51+
"
52+
53+
# 4. Tag pushen (triggert automatisch den Release-Workflow)
54+
git push && git push --tags
55+
```
56+
57+
### Was passiert automatisch:
58+
59+
1. GitHub Actions baut die Binaries für beide Architekturen
60+
2. Erstellt Release-Archives und berechnet SHA256-Checksums
61+
3. Lädt alles als GitHub Release hoch
62+
4. Klont das homebrew-tap Repository
63+
5. Aktualisiert die Formula mit neuer Version und SHA256-Checksums
64+
6. Committed und pusht die Änderungen ins homebrew-tap Repository
65+
66+
### Manueller Fallback:
67+
68+
Falls die automatische Aktualisierung fehlschlägt, kann die Homebrew Formula manuell aktualisiert werden:
69+
70+
```bash
71+
# SHA256 aus Release-Assets abrufen
72+
curl -L -o tide-aarch64.tar.gz https://github.com/BreathCodeFlow/tide/releases/download/v1.2.0/tide-aarch64-apple-darwin.tar.gz
73+
curl -L -o tide-x86_64.tar.gz https://github.com/BreathCodeFlow/tide/releases/download/v1.2.0/tide-x86_64-apple-darwin.tar.gz
74+
75+
shasum -a 256 tide-aarch64.tar.gz
76+
shasum -a 256 tide-x86_64.tar.gz
77+
78+
# homebrew-tap klonen und Formula aktualisieren
79+
git clone https://github.com/BreathCodeFlow/homebrew-tap.git
80+
cd homebrew-tap
81+
# Formula/tide.rb bearbeiten
82+
git add Formula/tide.rb
83+
git commit -m "chore: update tide formula to v1.2.0"
84+
git push
85+
```

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,58 @@ jobs:
7171
target/${{ matrix.target }}/release/${{ matrix.name }}.tar.gz.sha256
7272
env:
7373
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
update-homebrew:
76+
name: Update Homebrew Tap
77+
needs: build
78+
runs-on: macos-latest
79+
steps:
80+
- name: Checkout code
81+
uses: actions/checkout@v4
82+
83+
- name: Get version from tag
84+
id: get_version
85+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
86+
87+
- name: Download release assets
88+
run: |
89+
VERSION=${{ steps.get_version.outputs.VERSION }}
90+
91+
# Download both archives
92+
curl -L -o tide-aarch64-apple-darwin.tar.gz \
93+
"https://github.com/${{ github.repository }}/releases/download/v${VERSION}/tide-aarch64-apple-darwin.tar.gz"
94+
curl -L -o tide-x86_64-apple-darwin.tar.gz \
95+
"https://github.com/${{ github.repository }}/releases/download/v${VERSION}/tide-x86_64-apple-darwin.tar.gz"
96+
97+
# Calculate SHA256
98+
AARCH64_SHA=$(shasum -a 256 tide-aarch64-apple-darwin.tar.gz | awk '{print $1}')
99+
X86_64_SHA=$(shasum -a 256 tide-x86_64-apple-darwin.tar.gz | awk '{print $1}')
100+
101+
echo "AARCH64_SHA=${AARCH64_SHA}" >> $GITHUB_ENV
102+
echo "X86_64_SHA=${X86_64_SHA}" >> $GITHUB_ENV
103+
104+
- name: Clone homebrew tap
105+
run: |
106+
git clone https://github.com/BreathCodeFlow/homebrew-tap.git homebrew-tap
107+
108+
- name: Update formula
109+
run: |
110+
VERSION=${{ steps.get_version.outputs.VERSION }}
111+
112+
# Update version
113+
sed -i '' "s/version \".*\"/version \"${VERSION}\"/" homebrew-tap/Formula/tide.rb
114+
115+
# Update ARM64 SHA256
116+
sed -i '' "s/sha256 \".*\" # aarch64/sha256 \"${AARCH64_SHA}\" # aarch64/" homebrew-tap/Formula/tide.rb
117+
118+
# Update x86_64 SHA256
119+
sed -i '' "s/sha256 \".*\" # x86_64/sha256 \"${X86_64_SHA}\" # x86_64/" homebrew-tap/Formula/tide.rb
120+
121+
- name: Commit and push
122+
run: |
123+
cd homebrew-tap
124+
git config user.name "github-actions[bot]"
125+
git config user.email "github-actions[bot]@users.noreply.github.com"
126+
git add Formula/tide.rb
127+
git commit -m "chore: update tide formula to v${{ steps.get_version.outputs.VERSION }}"
128+
git push https://x-access-token:${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/BreathCodeFlow/homebrew-tap.git main

homebrew/tide.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ class Tide < Formula
77
on_macos do
88
if Hardware::CPU.arm?
99
url "https://github.com/BreathCodeFlow/tide/releases/download/v#{version}/tide-aarch64-apple-darwin.tar.gz"
10-
sha256 "REPLACE_WITH_ACTUAL_SHA256_FOR_AARCH64"
10+
sha256 "REPLACE_WITH_ACTUAL_SHA256_FOR_AARCH64" # aarch64
1111
else
1212
url "https://github.com/BreathCodeFlow/tide/releases/download/v#{version}/tide-x86_64-apple-darwin.tar.gz"
13-
sha256 "REPLACE_WITH_ACTUAL_SHA256_FOR_X86_64"
13+
sha256 "REPLACE_WITH_ACTUAL_SHA256_FOR_X86_64" # x86_64
1414
end
1515
end
1616

0 commit comments

Comments
 (0)