Skip to content

Commit 697d757

Browse files
committed
ci(release): automate homebrew tap updates
1 parent 9b8638b commit 697d757

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,90 @@ jobs:
129129
run: cd npm-pkg && npm publish --access=public
130130
env:
131131
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
132+
133+
update-homebrew-tap:
134+
name: Update Homebrew Tap
135+
needs: release
136+
runs-on: ubuntu-latest
137+
if: startsWith(github.ref, 'refs/tags/v') && secrets.HOMEBREW_TAP_GITHUB_TOKEN != ''
138+
steps:
139+
- name: Download all artifacts
140+
uses: actions/download-artifact@v4
141+
with:
142+
path: artifacts
143+
merge-multiple: true
144+
145+
- name: Resolve checksums
146+
id: checksums
147+
run: |
148+
set -euo pipefail
149+
SHA_MACOS_ARM=$(sha256sum artifacts/torah-aarch64-apple-darwin.tar.gz | awk '{print $1}')
150+
SHA_MACOS_INTEL=$(sha256sum artifacts/torah-x86_64-apple-darwin.tar.gz | awk '{print $1}')
151+
SHA_LINUX_ARM=$(sha256sum artifacts/torah-aarch64-unknown-linux-gnu.tar.gz | awk '{print $1}')
152+
SHA_LINUX_INTEL=$(sha256sum artifacts/torah-x86_64-unknown-linux-gnu.tar.gz | awk '{print $1}')
153+
VERSION="${GITHUB_REF#refs/tags/v}"
154+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
155+
echo "sha_macos_arm=${SHA_MACOS_ARM}" >> "$GITHUB_OUTPUT"
156+
echo "sha_macos_intel=${SHA_MACOS_INTEL}" >> "$GITHUB_OUTPUT"
157+
echo "sha_linux_arm=${SHA_LINUX_ARM}" >> "$GITHUB_OUTPUT"
158+
echo "sha_linux_intel=${SHA_LINUX_INTEL}" >> "$GITHUB_OUTPUT"
159+
160+
- name: Checkout tap repository
161+
uses: actions/checkout@v4
162+
with:
163+
repository: assafdori/homebrew-tap
164+
token: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
165+
path: homebrew-tap
166+
167+
- name: Write formula
168+
run: |
169+
set -euo pipefail
170+
mkdir -p homebrew-tap/Formula
171+
cat > homebrew-tap/Formula/torah.rb <<EOF
172+
class Torah < Formula
173+
desc "Torah TUI for terminal reading"
174+
homepage "https://github.com/assafdori/torah-cli"
175+
version "${{ steps.checksums.outputs.version }}"
176+
177+
on_macos do
178+
on_arm do
179+
url "https://github.com/assafdori/torah-cli/releases/download/v${{ steps.checksums.outputs.version }}/torah-aarch64-apple-darwin.tar.gz"
180+
sha256 "${{ steps.checksums.outputs.sha_macos_arm }}"
181+
end
182+
on_intel do
183+
url "https://github.com/assafdori/torah-cli/releases/download/v${{ steps.checksums.outputs.version }}/torah-x86_64-apple-darwin.tar.gz"
184+
sha256 "${{ steps.checksums.outputs.sha_macos_intel }}"
185+
end
186+
end
187+
188+
on_linux do
189+
on_arm do
190+
url "https://github.com/assafdori/torah-cli/releases/download/v${{ steps.checksums.outputs.version }}/torah-aarch64-unknown-linux-gnu.tar.gz"
191+
sha256 "${{ steps.checksums.outputs.sha_linux_arm }}"
192+
end
193+
on_intel do
194+
url "https://github.com/assafdori/torah-cli/releases/download/v${{ steps.checksums.outputs.version }}/torah-x86_64-unknown-linux-gnu.tar.gz"
195+
sha256 "${{ steps.checksums.outputs.sha_linux_intel }}"
196+
end
197+
end
198+
199+
def install
200+
bin.install "torah"
201+
end
202+
203+
test do
204+
assert_match "Usage", shell_output("#{bin}/torah --help")
205+
end
206+
end
207+
EOF
208+
209+
- name: Commit and push formula update
210+
run: |
211+
set -euo pipefail
212+
cd homebrew-tap
213+
git config user.name "github-actions[bot]"
214+
git config user.email "github-actions[bot]@users.noreply.github.com"
215+
git add Formula/torah.rb
216+
git diff --staged --quiet && exit 0
217+
git commit -m "torah v${{ steps.checksums.outputs.version }}"
218+
git push

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ Or with curl:
1818
curl -fsSL https://raw.githubusercontent.com/assafdori/torah-cli/main/install.sh | sh
1919
```
2020

21+
Or with Homebrew:
22+
23+
```sh
24+
brew tap assafdori/tap
25+
brew install torah
26+
```
27+
2128
## Usage
2229

2330
Launch the interactive TUI browser:

0 commit comments

Comments
 (0)