Skip to content

Commit d41837e

Browse files
committed
Update homebrew deploy yo use deploy key
1 parent a8bc7d1 commit d41837e

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ jobs:
354354
needs: [release, build_and_package_macos, publish_portable_assets]
355355
runs-on: ubuntu-latest
356356
env:
357-
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
357+
HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
358358
steps:
359359
- name: Checkout code
360360
uses: actions/checkout@v4
@@ -376,12 +376,12 @@ jobs:
376376
name: portable-x64
377377
path: dist/portable/x64
378378

379-
- name: Skip when tap token is unavailable
380-
if: env.HOMEBREW_TAP_TOKEN == ''
381-
run: echo "HOMEBREW_TAP_TOKEN is not set; skipping Homebrew tap update."
379+
- name: Skip when deploy key is unavailable
380+
if: env.HOMEBREW_TAP_DEPLOY_KEY == ''
381+
run: echo "HOMEBREW_TAP_DEPLOY_KEY is not set; skipping Homebrew tap update."
382382

383383
- name: Generate formula
384-
if: env.HOMEBREW_TAP_TOKEN != ''
384+
if: env.HOMEBREW_TAP_DEPLOY_KEY != ''
385385
run: |
386386
VERSION="${{ needs.release.outputs.version }}"
387387
FORMULA_BASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}"
@@ -394,24 +394,23 @@ jobs:
394394
--base-url "$FORMULA_BASE_URL" \
395395
--out dist/homebrew/Formula/xcodebuildmcp.rb
396396
397+
- name: Configure SSH for tap repository
398+
if: env.HOMEBREW_TAP_DEPLOY_KEY != ''
399+
uses: webfactory/ssh-agent@v0.9.0
400+
with:
401+
ssh-private-key: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
402+
397403
- name: Update tap repository
398-
if: env.HOMEBREW_TAP_TOKEN != ''
399-
env:
400-
GH_TOKEN: ${{ env.HOMEBREW_TAP_TOKEN }}
404+
if: env.HOMEBREW_TAP_DEPLOY_KEY != ''
401405
run: |
402406
VERSION="${{ needs.release.outputs.version }}"
403-
DEFAULT_BRANCH="main"
404-
gh repo clone ${{ github.repository_owner }}/homebrew-xcodebuildmcp tap-repo
407+
git clone git@github.com:${{ github.repository_owner }}/homebrew-xcodebuildmcp.git tap-repo
405408
mkdir -p tap-repo/Formula
406409
cp dist/homebrew/Formula/xcodebuildmcp.rb tap-repo/Formula/xcodebuildmcp.rb
407410
cd tap-repo
408411
git config user.name "github-actions[bot]"
409412
git config user.email "github-actions[bot]@users.noreply.github.com"
410-
git remote set-url origin "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/${{ github.repository_owner }}/homebrew-xcodebuildmcp.git"
411-
DETECTED_BRANCH="$(gh repo view ${{ github.repository_owner }}/homebrew-xcodebuildmcp --json defaultBranchRef -q .defaultBranchRef.name 2>/dev/null || true)"
412-
if [ -n "$DETECTED_BRANCH" ]; then
413-
DEFAULT_BRANCH="$DETECTED_BRANCH"
414-
fi
413+
DEFAULT_BRANCH="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's|refs/remotes/origin/||')"
415414
if ! git rev-parse --verify HEAD >/dev/null 2>&1; then
416415
echo "Tap repo has no commits; bootstrapping ${DEFAULT_BRANCH}."
417416
git checkout -b "$DEFAULT_BRANCH"

0 commit comments

Comments
 (0)