From 468aac0bf87ecbd08e5d510b45e4dcaf7e8daa32 Mon Sep 17 00:00:00 2001 From: Matt Walters Date: Sat, 14 Feb 2026 20:01:50 -0600 Subject: [PATCH 1/2] fix: use PR workflow for homebrew tap updates Branch protection on homebrew-tap requires changes via PR. Switch from direct push to creating a branch, opening a PR, and auto-merging with squash. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7726f36..e71377b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -313,14 +313,29 @@ jobs: - name: Push to Homebrew tap env: - GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} + GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} run: | - git clone https://x-access-token:${GITHUB_TOKEN}@github.com/harmony-labs/homebrew-tap.git tap + VERSION="${{ steps.version.outputs.version }}" + BRANCH="update-meta-cli-${VERSION}" + + gh repo clone harmony-labs/homebrew-tap tap mkdir -p tap/Formula cp meta-cli.rb tap/Formula/ cd tap git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add Formula/meta-cli.rb - git commit -m "Update meta-cli to v${{ steps.version.outputs.version }}" - git push + if ! git diff --cached --quiet; then + git checkout -b "$BRANCH" + git commit -m "Update meta-cli to v${VERSION}" + git push -u origin "$BRANCH" + gh pr create \ + --title "Update meta-cli to v${VERSION}" \ + --body "Automated formula update from meta release v${VERSION}." \ + --repo harmony-labs/homebrew-tap + gh pr merge "$BRANCH" \ + --auto --squash \ + --repo harmony-labs/homebrew-tap + else + echo "Formula unchanged, skipping commit" + fi From 451358d259e2632205ac88b3bb46021cbcff16c2 Mon Sep 17 00:00:00 2001 From: Matt Walters Date: Sat, 14 Feb 2026 20:13:14 -0600 Subject: [PATCH 2/2] fix: make homebrew tap update idempotent for re-runs - Force push branch in case it exists from a previous failed run - Check if PR exists before creating a new one - Gracefully handle auto-merge failure (may require approvals) Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e71377b..2e9bf49 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -328,14 +328,18 @@ jobs: if ! git diff --cached --quiet; then git checkout -b "$BRANCH" git commit -m "Update meta-cli to v${VERSION}" - git push -u origin "$BRANCH" - gh pr create \ - --title "Update meta-cli to v${VERSION}" \ - --body "Automated formula update from meta release v${VERSION}." \ - --repo harmony-labs/homebrew-tap + # Force push in case branch exists from a previous failed run + git push -f -u origin "$BRANCH" + # Create PR only if one doesn't already exist + if ! gh pr view "$BRANCH" --repo harmony-labs/homebrew-tap &>/dev/null; then + gh pr create \ + --title "Update meta-cli to v${VERSION}" \ + --body "Automated formula update from meta release v${VERSION}." \ + --repo harmony-labs/homebrew-tap + fi gh pr merge "$BRANCH" \ --auto --squash \ - --repo harmony-labs/homebrew-tap + --repo harmony-labs/homebrew-tap || echo "Auto-merge setup failed (may require approvals)" else echo "Formula unchanged, skipping commit" fi