Skip to content

Commit bf2ff4e

Browse files
committed
ci(release): Automate Homebrew deploys for tag releases
Run Homebrew tap updates only for tag-push release runs and push formula\nupdates directly to the tap default branch after release checks pass.\nManual workflow_dispatch runs now avoid Homebrew deployment entirely,\nmatching npm dry-run behavior.\n\nCo-Authored-By: Claude <noreply@anthropic.com>
1 parent 322fc0d commit bf2ff4e

1 file changed

Lines changed: 12 additions & 41 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ jobs:
361361
--clobber
362362
363363
update_homebrew_tap:
364-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
364+
if: github.event_name == 'push'
365365
needs: [release, build_and_package_macos]
366366
runs-on: ubuntu-latest
367367
env:
@@ -396,9 +396,6 @@ jobs:
396396
run: |
397397
VERSION="${{ needs.release.outputs.version }}"
398398
FORMULA_BASE_URL="https://github.com/cameroncooke/XcodeBuildMCP/releases/download/v${VERSION}"
399-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
400-
FORMULA_BASE_URL="https://raw.githubusercontent.com/cameroncooke/homebrew-xcodebuildmcp/main/artifacts/${VERSION}"
401-
fi
402399
ARM64_SHA="$(awk '{print $1}' dist/portable/arm64/xcodebuildmcp-${VERSION}-darwin-arm64.tar.gz.sha256)"
403400
X64_SHA="$(awk '{print $1}' dist/portable/x64/xcodebuildmcp-${VERSION}-darwin-x64.tar.gz.sha256)"
404401
npm run homebrew:formula -- \
@@ -408,60 +405,34 @@ jobs:
408405
--base-url "$FORMULA_BASE_URL" \
409406
--out dist/homebrew/Formula/xcodebuildmcp.rb
410407
411-
- name: Create pull request in tap repo
408+
- name: Update tap repository
412409
if: env.HOMEBREW_TAP_TOKEN != ''
413410
env:
414411
GH_TOKEN: ${{ env.HOMEBREW_TAP_TOKEN }}
415412
run: |
416413
VERSION="${{ needs.release.outputs.version }}"
417-
BRANCH="xcodebuildmcp-v${VERSION}"
418414
DEFAULT_BRANCH="main"
419-
ADD_TAP_ARTIFACTS="false"
420-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
421-
ADD_TAP_ARTIFACTS="true"
422-
fi
423415
git clone "https://x-access-token:${GH_TOKEN}@github.com/cameroncooke/homebrew-xcodebuildmcp.git" tap-repo
424416
mkdir -p tap-repo/Formula
425-
if [ "$ADD_TAP_ARTIFACTS" = "true" ]; then
426-
mkdir -p "tap-repo/artifacts/${VERSION}"
427-
cp "dist/portable/arm64/xcodebuildmcp-${VERSION}-darwin-arm64.tar.gz" "tap-repo/artifacts/${VERSION}/"
428-
cp "dist/portable/arm64/xcodebuildmcp-${VERSION}-darwin-arm64.tar.gz.sha256" "tap-repo/artifacts/${VERSION}/"
429-
cp "dist/portable/x64/xcodebuildmcp-${VERSION}-darwin-x64.tar.gz" "tap-repo/artifacts/${VERSION}/"
430-
cp "dist/portable/x64/xcodebuildmcp-${VERSION}-darwin-x64.tar.gz.sha256" "tap-repo/artifacts/${VERSION}/"
431-
fi
432417
cp dist/homebrew/Formula/xcodebuildmcp.rb tap-repo/Formula/xcodebuildmcp.rb
433418
cd tap-repo
434419
git config user.name "github-actions[bot]"
435420
git config user.email "github-actions[bot]@users.noreply.github.com"
436-
if ! git rev-parse --verify HEAD >/dev/null 2>&1; then
437-
echo "Tap repo has no commits; bootstrapping ${DEFAULT_BRANCH}."
438-
git checkout -b "$DEFAULT_BRANCH"
439-
git add Formula/xcodebuildmcp.rb
440-
if [ "$ADD_TAP_ARTIFACTS" = "true" ]; then
441-
git add "artifacts/${VERSION}"
442-
fi
443-
git commit -m "Initialize xcodebuildmcp formula ${VERSION}"
444-
git push origin "$DEFAULT_BRANCH"
445-
exit 0
446-
fi
447421
DETECTED_BRANCH="$(gh repo view cameroncooke/homebrew-xcodebuildmcp --json defaultBranchRef -q .defaultBranchRef.name 2>/dev/null || true)"
448422
if [ -n "$DETECTED_BRANCH" ]; then
449423
DEFAULT_BRANCH="$DETECTED_BRANCH"
450424
fi
451-
if git diff --quiet Formula/xcodebuildmcp.rb; then
452-
echo "Formula already up to date; skipping PR."
453-
exit 0
425+
if ! git rev-parse --verify HEAD >/dev/null 2>&1; then
426+
echo "Tap repo has no commits; bootstrapping ${DEFAULT_BRANCH}."
427+
git checkout -b "$DEFAULT_BRANCH"
428+
else
429+
git checkout "$DEFAULT_BRANCH"
430+
git pull --ff-only origin "$DEFAULT_BRANCH"
454431
fi
455-
git checkout -B "$BRANCH"
456432
git add Formula/xcodebuildmcp.rb
457-
if [ "$ADD_TAP_ARTIFACTS" = "true" ]; then
458-
git add "artifacts/${VERSION}"
433+
if git diff --cached --quiet; then
434+
echo "Formula already up to date; nothing to push."
435+
exit 0
459436
fi
460437
git commit -m "xcodebuildmcp ${VERSION}"
461-
git push --set-upstream origin "$BRANCH"
462-
gh pr create \
463-
--repo cameroncooke/homebrew-xcodebuildmcp \
464-
--title "Update xcodebuildmcp to ${VERSION}" \
465-
--body "Automated formula update for xcodebuildmcp ${VERSION}." \
466-
--base "$DEFAULT_BRANCH" \
467-
--head "$BRANCH"
438+
git push origin "$DEFAULT_BRANCH"

0 commit comments

Comments
 (0)