From ef8585bd2eed088eaf46dcd2e8e49dd0065b32d9 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Thu, 6 Nov 2025 20:35:25 -0800 Subject: [PATCH] feat: Add automatic Homebrew formula update to release workflow --- .github/workflows/release.yml | 88 +++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca46fea0..b9e813a0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,3 +63,91 @@ jobs: run: | cd integrations/beads-mcp uv tool run twine upload dist/* + + update-homebrew: + runs-on: ubuntu-latest + needs: goreleaser + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get release info + id: release + run: | + TAG="${GITHUB_REF#refs/tags/}" + echo "tag=${TAG}" >> $GITHUB_OUTPUT + echo "version=${TAG#v}" >> $GITHUB_OUTPUT + + - name: Download checksums + run: | + curl -sL "https://github.com/steveyegge/beads/releases/download/${{ steps.release.outputs.tag }}/checksums.txt" -o checksums.txt + + - name: Extract checksums + id: checksums + run: | + echo "darwin_amd64=$(grep 'darwin_amd64.tar.gz' checksums.txt | awk '{print $1}')" >> $GITHUB_OUTPUT + echo "darwin_arm64=$(grep 'darwin_arm64.tar.gz' checksums.txt | awk '{print $1}')" >> $GITHUB_OUTPUT + echo "linux_amd64=$(grep 'linux_amd64.tar.gz' checksums.txt | awk '{print $1}')" >> $GITHUB_OUTPUT + echo "linux_arm64=$(grep 'linux_arm64.tar.gz' checksums.txt | awk '{print $1}')" >> $GITHUB_OUTPUT + + - name: Update Homebrew formula + run: | + cat > Formula/bd.rb <<'EOF' + class Bd < Formula + desc "AI-supervised issue tracker for coding workflows" + homepage "https://github.com/steveyegge/beads" + version "${{ steps.release.outputs.version }}" + license "MIT" + + on_macos do + if Hardware::CPU.arm? + url "https://github.com/steveyegge/beads/releases/download/v#{version}/beads_#{version}_darwin_arm64.tar.gz" + sha256 "${{ steps.checksums.outputs.darwin_arm64 }}" + else + url "https://github.com/steveyegge/beads/releases/download/v#{version}/beads_#{version}_darwin_amd64.tar.gz" + sha256 "${{ steps.checksums.outputs.darwin_amd64 }}" + end + end + + on_linux do + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "https://github.com/steveyegge/beads/releases/download/v#{version}/beads_#{version}_linux_arm64.tar.gz" + sha256 "${{ steps.checksums.outputs.linux_arm64 }}" + else + url "https://github.com/steveyegge/beads/releases/download/v#{version}/beads_#{version}_linux_amd64.tar.gz" + sha256 "${{ steps.checksums.outputs.linux_amd64 }}" + end + end + + def install + bin.install "bd" + end + + test do + system "#{bin}/bd", "version" + end + end + EOF + + - name: Push to homebrew-beads + env: + HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} + run: | + if [ -z "$HOMEBREW_TAP_TOKEN" ]; then + echo "::warning::HOMEBREW_TAP_TOKEN not set - skipping Homebrew update" + echo "To enable automatic Homebrew updates:" + echo "1. Create a Personal Access Token with 'repo' scope" + echo "2. Add it as HOMEBREW_TAP_TOKEN in repository secrets" + exit 0 + fi + + git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/steveyegge/homebrew-beads.git" tap + cp Formula/bd.rb tap/Formula/bd.rb + cd tap + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add Formula/bd.rb + git commit -m "Update bd to ${{ steps.release.outputs.version }}" + git push