Skip to content

Commit 255795f

Browse files
cameroncookeclaude
andcommitted
ci(release): Handle artifact roots and empty tap bootstrap
Resolve portable artifact roots dynamically after download to avoid path layout mismatches in the universal packaging job. Bootstrap an empty Homebrew tap by creating Formula/, committing to the default branch, and exiting cleanly. For non-empty repos, detect default branch for PR base and keep formula updates on version branch. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 96e4d1d commit 255795f

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

.github/workflows/release.yml

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,29 @@ jobs:
290290
name: portable-x64
291291
path: dist/portable/x64
292292

293+
- name: Resolve extracted arch roots
294+
id: resolve_roots
295+
run: |
296+
VERSION="${{ needs.release.outputs.version }}"
297+
ARM64_ROOT="$(find dist/portable/arm64 -type d -name "xcodebuildmcp-${VERSION}-darwin-arm64" -print -quit)"
298+
X64_ROOT="$(find dist/portable/x64 -type d -name "xcodebuildmcp-${VERSION}-darwin-x64" -print -quit)"
299+
if [ -z "$ARM64_ROOT" ] || [ -z "$X64_ROOT" ]; then
300+
echo "Failed to resolve extracted arch roots."
301+
echo "arm64 root: ${ARM64_ROOT:-<missing>}"
302+
echo "x64 root: ${X64_ROOT:-<missing>}"
303+
echo "--- dist/portable tree (depth 4) ---"
304+
find dist/portable -maxdepth 4 -print
305+
exit 1
306+
fi
307+
echo "ARM64_ROOT=$ARM64_ROOT" >> "$GITHUB_OUTPUT"
308+
echo "X64_ROOT=$X64_ROOT" >> "$GITHUB_OUTPUT"
309+
293310
- name: Build universal portable artifact
294311
run: |
295312
npm run package:macos:universal -- \
296313
--version "${{ needs.release.outputs.version }}" \
297-
--arm64-root "dist/portable/arm64/xcodebuildmcp-${{ needs.release.outputs.version }}-darwin-arm64" \
298-
--x64-root "dist/portable/x64/xcodebuildmcp-${{ needs.release.outputs.version }}-darwin-x64"
314+
--arm64-root "${{ steps.resolve_roots.outputs.ARM64_ROOT }}" \
315+
--x64-root "${{ steps.resolve_roots.outputs.X64_ROOT }}"
299316
300317
- name: Verify universal portable artifact
301318
run: |
@@ -396,22 +413,36 @@ jobs:
396413
run: |
397414
VERSION="${{ needs.release.outputs.version }}"
398415
BRANCH="xcodebuildmcp-v${VERSION}"
416+
DEFAULT_BRANCH="main"
399417
git clone "https://x-access-token:${GH_TOKEN}@github.com/cameroncooke/homebrew-xcodebuildmcp.git" tap-repo
418+
mkdir -p tap-repo/Formula
400419
cp dist/homebrew/Formula/xcodebuildmcp.rb tap-repo/Formula/xcodebuildmcp.rb
401420
cd tap-repo
421+
git config user.name "github-actions[bot]"
422+
git config user.email "github-actions[bot]@users.noreply.github.com"
423+
if ! git rev-parse --verify HEAD >/dev/null 2>&1; then
424+
echo "Tap repo has no commits; bootstrapping ${DEFAULT_BRANCH}."
425+
git checkout -b "$DEFAULT_BRANCH"
426+
git add Formula/xcodebuildmcp.rb
427+
git commit -m "Initialize xcodebuildmcp formula ${VERSION}"
428+
git push origin "$DEFAULT_BRANCH"
429+
exit 0
430+
fi
431+
DETECTED_BRANCH="$(gh repo view cameroncooke/homebrew-xcodebuildmcp --json defaultBranchRef -q .defaultBranchRef.name 2>/dev/null || true)"
432+
if [ -n "$DETECTED_BRANCH" ]; then
433+
DEFAULT_BRANCH="$DETECTED_BRANCH"
434+
fi
402435
if git diff --quiet Formula/xcodebuildmcp.rb; then
403436
echo "Formula already up to date; skipping PR."
404437
exit 0
405438
fi
406-
git checkout -b "$BRANCH"
407-
git config user.name "github-actions[bot]"
408-
git config user.email "github-actions[bot]@users.noreply.github.com"
439+
git checkout -B "$BRANCH"
409440
git add Formula/xcodebuildmcp.rb
410441
git commit -m "xcodebuildmcp ${VERSION}"
411-
git push origin "$BRANCH"
442+
git push --set-upstream origin "$BRANCH"
412443
gh pr create \
413444
--repo cameroncooke/homebrew-xcodebuildmcp \
414445
--title "Update xcodebuildmcp to ${VERSION}" \
415446
--body "Automated formula update for xcodebuildmcp ${VERSION}." \
416-
--base main \
447+
--base "$DEFAULT_BRANCH" \
417448
--head "$BRANCH"

0 commit comments

Comments
 (0)