Skip to content

Commit 48f4294

Browse files
authored
Improve bottle metadata handling in workflow
Refactor bottle metadata merging and commit logic.
1 parent 3ef1347 commit 48f4294

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

.github/workflows/bottle.yml

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -218,31 +218,22 @@ jobs:
218218
ls -la bottles/
219219
exit 1
220220
fi
221-
221+
222222
echo "Merging bottle metadata from:"
223223
printf '%s\n' "${JSON_BOTTLES[@]}"
224-
224+
225+
BEFORE_SHA="$(git rev-parse HEAD)"
225226
brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}"
226-
227-
# brew bottle --write updates the tapped formula (setup-homebrew’s tap location).
228-
# Copy back into the checked-out repo for committing.
229-
TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-mfc"
230-
cp "${TAP_DIR}/Formula/mfc.rb" Formula/mfc.rb
231-
232-
if git diff --quiet -- Formula/mfc.rb; then
233-
echo "bottle_updated=false" >> "$GITHUB_OUTPUT"
234-
else
227+
AFTER_SHA="$(git rev-parse HEAD)"
228+
229+
if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then
230+
echo "✅ brew bottle --write created commit ${AFTER_SHA}"
235231
echo "bottle_updated=true" >> "$GITHUB_OUTPUT"
232+
else
233+
echo "ℹ️ No commit created (bottles unchanged or already present)"
234+
echo "bottle_updated=false" >> "$GITHUB_OUTPUT"
236235
fi
237236

238-
- name: Commit formula update if changed
239-
if: steps.merge.outputs.bottle_updated == 'true'
240-
shell: bash
241-
run: |
242-
set -euo pipefail
243-
git add Formula/mfc.rb
244-
git commit -m "mfc: bottles for v${{ steps.meta.outputs.version }}"
245-
246237
- name: Push bottle updates if changed
247238
if: steps.merge.outputs.bottle_updated == 'true'
248239
shell: bash

0 commit comments

Comments
 (0)