Skip to content

Commit 18ccb8e

Browse files
authored
Refactor bottle metadata merge step in workflow
1 parent b1c32d0 commit 18ccb8e

File tree

1 file changed

+42
-33
lines changed

1 file changed

+42
-33
lines changed

.github/workflows/bottle.yml

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -242,40 +242,49 @@ jobs:
242242
shell: bash
243243
run: |
244244
set -euo pipefail
245-
brew tap mflowcode/local "${GITHUB_WORKSPACE}" --force-auto-update || true
246-
brew tap --list | grep -q '^mflowcode/local$'
245+
246+
# Ensure a clean state if a previous run left the tap installed
247+
brew untap mflowcode/local >/dev/null 2>&1 || true
248+
249+
# Tap the checked-out repository as a local tap
250+
brew tap mflowcode/local "${GITHUB_WORKSPACE}"
251+
252+
# Verify the tap exists (brew tap with no args lists taps)
253+
brew tap | grep -q '^mflowcode/local$'
254+
255+
# Verify the formula resolves
247256
brew info mflowcode/local/mfc
248-
249-
- name: Merge bottle metadata into formula
250-
id: merge
251-
run: |
252-
set -euo pipefail
253-
254-
JSON_BOTTLES=(bottles/*.bottle*.json)
255-
if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then
256-
echo "No bottle metadata (*.bottle*.json) found in bottles/"
257-
ls -la bottles/
258-
exit 1
259-
fi
260-
261-
echo "Merging bottle metadata from:"
262-
printf '%s\n' "${JSON_BOTTLES[@]}"
263-
264-
BEFORE_SHA=$(git rev-parse HEAD)
265-
echo "HEAD before merge: ${BEFORE_SHA}"
266-
267-
brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}"
268-
269-
AFTER_SHA=$(git rev-parse HEAD)
270-
echo "HEAD after merge: ${AFTER_SHA}"
271-
272-
if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then
273-
echo "✅ New bottle commit created by brew bottle --write"
274-
echo "bottle_updated=true" >> "$GITHUB_OUTPUT"
275-
else
276-
echo "ℹ️ No new commit (bottles unchanged or already present)"
277-
echo "bottle_updated=false" >> "$GITHUB_OUTPUT"
278-
fi
257+
258+
- name: Merge bottle metadata into formula
259+
id: merge
260+
run: |
261+
set -euo pipefail
262+
263+
JSON_BOTTLES=(bottles/*.bottle*.json)
264+
if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then
265+
echo "No bottle metadata (*.bottle*.json) found in bottles/"
266+
ls -la bottles/
267+
exit 1
268+
fi
269+
270+
echo "Merging bottle metadata from:"
271+
printf '%s\n' "${JSON_BOTTLES[@]}"
272+
273+
BEFORE_SHA=$(git rev-parse HEAD)
274+
echo "HEAD before merge: ${BEFORE_SHA}"
275+
276+
brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}"
277+
278+
AFTER_SHA=$(git rev-parse HEAD)
279+
echo "HEAD after merge: ${AFTER_SHA}"
280+
281+
if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then
282+
echo "✅ New bottle commit created by brew bottle --write"
283+
echo "bottle_updated=true" >> "$GITHUB_OUTPUT"
284+
else
285+
echo "ℹ️ No new commit (bottles unchanged or already present)"
286+
echo "bottle_updated=false" >> "$GITHUB_OUTPUT"
287+
fi
279288

280289
- name: Push bottle updates if changed
281290
if: steps.merge.outputs.bottle_updated == 'true'

0 commit comments

Comments
 (0)