Skip to content

Commit 591fca5

Browse files
timvwclaude
andcommitted
feat: automate Homebrew formula updates in release workflow
Add update-formula job that automatically updates the homebrew-tap formula after each release. This ensures the formula always has correct source and bottle SHA256s, eliminating manual updates and preventing broken Renovate PRs. The job: - Extracts bottle SHA256s from release artifacts - Downloads and calculates source tarball SHA256 - Clones homebrew-tap and updates Formula/wt.rb - Commits and pushes changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e7565e1 commit 591fca5

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,102 @@ jobs:
174174
--title "Release ${{ github.ref_name }}" \
175175
--generate-notes \
176176
release/*
177+
178+
update-formula:
179+
name: Update Homebrew Formula
180+
needs: release
181+
runs-on: ubuntu-latest
182+
183+
steps:
184+
- name: Generate GitHub App token
185+
id: generate-token
186+
uses: actions/create-github-app-token@v1
187+
with:
188+
app-id: ${{ secrets.BOT_APP_ID }}
189+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
190+
repositories: |
191+
wt
192+
homebrew-tap
193+
194+
- name: Download checksums artifact
195+
uses: actions/download-artifact@v4
196+
with:
197+
path: artifacts/
198+
199+
- name: Extract version and checksums
200+
id: version
201+
run: |
202+
VERSION=${GITHUB_REF_NAME#v}
203+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
204+
205+
# Find checksums.txt in artifacts
206+
CHECKSUMS_FILE=$(find artifacts -name "checksums.txt" -type f | head -1)
207+
208+
# Extract bottle SHA256s from checksums
209+
AARCH64_LINUX=$(grep "wt-${VERSION}.aarch64_linux.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
210+
ARM64_SONOMA=$(grep "wt-${VERSION}.arm64_sonoma.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
211+
VENTURA=$(grep "wt-${VERSION}.ventura.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
212+
X86_64_LINUX=$(grep "wt-${VERSION}.x86_64_linux.bottle.tar.gz" "$CHECKSUMS_FILE" | awk '{print $1}')
213+
214+
echo "AARCH64_LINUX=$AARCH64_LINUX" >> $GITHUB_OUTPUT
215+
echo "ARM64_SONOMA=$ARM64_SONOMA" >> $GITHUB_OUTPUT
216+
echo "VENTURA=$VENTURA" >> $GITHUB_OUTPUT
217+
echo "X86_64_LINUX=$X86_64_LINUX" >> $GITHUB_OUTPUT
218+
219+
- name: Download source tarball and calculate SHA256
220+
id: source
221+
run: |
222+
VERSION=${{ steps.version.outputs.VERSION }}
223+
wget "https://github.com/timvw/wt/archive/refs/tags/v${VERSION}.tar.gz" -O source.tar.gz
224+
SOURCE_SHA256=$(shasum -a 256 source.tar.gz | awk '{print $1}')
225+
echo "SHA256=$SOURCE_SHA256" >> $GITHUB_OUTPUT
226+
227+
- name: Clone homebrew-tap repository
228+
run: |
229+
git clone https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/timvw/homebrew-tap.git
230+
231+
- name: Update formula
232+
run: |
233+
cd homebrew-tap
234+
VERSION=${{ steps.version.outputs.VERSION }}
235+
236+
# Update the formula file
237+
cat > Formula/wt.rb << 'EOF'
238+
class Wt < Formula
239+
desc "Git worktree helper"
240+
homepage "https://github.com/timvw/wt"
241+
url "https://github.com/timvw/wt/archive/refs/tags/v${{ steps.version.outputs.VERSION }}.tar.gz"
242+
sha256 "${{ steps.source.outputs.SHA256 }}"
243+
license "MIT"
244+
head "https://github.com/timvw/wt.git", branch: "main"
245+
246+
bottle do
247+
root_url "https://github.com/timvw/wt/releases/download/v${{ steps.version.outputs.VERSION }}"
248+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "${{ steps.version.outputs.ARM64_SONOMA }}"
249+
sha256 cellar: :any_skip_relocation, ventura: "${{ steps.version.outputs.VENTURA }}"
250+
sha256 cellar: :any_skip_relocation, x86_64_linux: "${{ steps.version.outputs.X86_64_LINUX }}"
251+
sha256 cellar: :any_skip_relocation, aarch64_linux: "${{ steps.version.outputs.AARCH64_LINUX }}"
252+
end
253+
254+
def install
255+
bin.install "wt"
256+
end
257+
258+
test do
259+
assert_match "wt version", shell_output("#{bin}/wt version")
260+
end
261+
end
262+
EOF
263+
264+
- name: Commit and push changes
265+
run: |
266+
cd homebrew-tap
267+
git config user.name "timvw-ci-bot[bot]"
268+
git config user.email "timvw-ci-bot[bot]@users.noreply.github.com"
269+
git add Formula/wt.rb
270+
git commit -m "chore: update wt formula to v${{ steps.version.outputs.VERSION }}
271+
272+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
273+
274+
Co-Authored-By: Claude <noreply@anthropic.com>"
275+
git push

0 commit comments

Comments
 (0)