|
25 | 25 | - name: Set up Homebrew |
26 | 26 | uses: Homebrew/actions/setup-homebrew@master |
27 | 27 |
|
| 28 | + - name: Ensure no conflicting taps provide mfc |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + set -euo pipefail |
| 32 | + brew untap mflowcode/mfc >/dev/null 2>&1 || true |
| 33 | + brew untap mflowcode/local >/dev/null 2>&1 || true |
| 34 | + |
28 | 35 | - name: Test tarball download |
29 | 36 | run: | |
30 | 37 | curl -I "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" |
@@ -238,79 +245,82 @@ jobs: |
238 | 245 | echo "Bottles ready for upload:" |
239 | 246 | ls -1 bottles/*.bottle.* |
240 | 247 |
|
241 | | - - name: Tap this checkout as mflowcode/local (so brew can find mflowcode/local/mfc) |
| 248 | + - name: Ensure no conflicting taps provide mfc (merge job) |
242 | 249 | shell: bash |
243 | 250 | run: | |
244 | 251 | set -euo pipefail |
245 | | - |
246 | | - # Ensure a clean state if a previous run left the tap installed |
| 252 | + brew untap mflowcode/mfc >/dev/null 2>&1 || true |
247 | 253 | brew untap mflowcode/local >/dev/null 2>&1 || true |
248 | 254 | |
249 | | - # Tap the checked-out repository as a local tap |
250 | | - brew tap mflowcode/local "${GITHUB_WORKSPACE}" |
| 255 | + - name: Create temp tap for merge and copy formula into it |
| 256 | + shell: bash |
| 257 | + run: | |
| 258 | + set -euo pipefail |
| 259 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 260 | + git config --global user.name "github-actions[bot]" |
251 | 261 | |
252 | | - # Verify the tap exists (brew tap with no args lists taps) |
253 | | - brew tap | grep -q '^mflowcode/local$' |
| 262 | + brew tap-new mflowcode/local |
| 263 | + TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" |
| 264 | + mkdir -p "${TAP_DIR}/Formula" |
| 265 | + cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb" |
254 | 266 |
|
255 | | - # Verify the formula resolves |
256 | 267 | brew info mflowcode/local/mfc |
257 | 268 |
|
258 | | - - name: Merge bottle metadata into formula |
259 | | - id: merge |
260 | | - run: | |
261 | | - set -euo pipefail |
| 269 | + - name: Merge bottle metadata into formula |
| 270 | + id: merge |
| 271 | + shell: bash |
| 272 | + run: | |
| 273 | + set -euo pipefail |
262 | 274 | |
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 |
| 275 | + JSON_BOTTLES=(bottles/*.bottle*.json) |
| 276 | + if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then |
| 277 | + echo "No bottle metadata (*.bottle*.json) found in bottles/" |
| 278 | + ls -la bottles/ |
| 279 | + exit 1 |
| 280 | + fi |
269 | 281 |
|
270 | | - echo "Merging bottle metadata from:" |
271 | | - printf '%s\n' "${JSON_BOTTLES[@]}" |
| 282 | + TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" |
272 | 283 |
|
273 | | - BEFORE_SHA=$(git rev-parse HEAD) |
274 | | - echo "HEAD before merge: ${BEFORE_SHA}" |
| 284 | + echo "Merging bottle metadata from:" |
| 285 | + printf '%s\n' "${JSON_BOTTLES[@]}" |
275 | 286 |
|
276 | | - brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" |
| 287 | + brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" |
277 | 288 |
|
278 | | - AFTER_SHA=$(git rev-parse HEAD) |
279 | | - echo "HEAD after merge: ${AFTER_SHA}" |
| 289 | + # Copy the updated formula back into this checkout so git add works here |
| 290 | + cp "${TAP_DIR}/Formula/mfc.rb" Formula/mfc.rb |
280 | 291 |
|
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 |
| 292 | + if git diff --quiet -- Formula/mfc.rb; then |
| 293 | + echo "bottle_updated=false" >> "$GITHUB_OUTPUT" |
| 294 | + else |
| 295 | + echo "bottle_updated=true" >> "$GITHUB_OUTPUT" |
| 296 | + fi |
288 | 297 |
|
| 298 | + - name: Commit formula update if changed |
| 299 | + if: steps.merge.outputs.bottle_updated == 'true' |
| 300 | + shell: bash |
| 301 | + run: | |
| 302 | + set -euo pipefail |
| 303 | + git add Formula/mfc.rb |
| 304 | + if git diff --cached --quiet; then |
| 305 | + echo "No changes staged; skipping commit." |
| 306 | + exit 0 |
| 307 | + fi |
| 308 | + git commit -m "mfc: bottles for v${{ steps.meta.outputs.version }}" |
| 309 | + |
289 | 310 | - name: Push bottle updates if changed |
290 | 311 | if: steps.merge.outputs.bottle_updated == 'true' |
| 312 | + shell: bash |
291 | 313 | run: | |
292 | 314 | set -euo pipefail |
293 | | -
|
294 | | - echo "Pushing bottle update commit..." |
295 | | - git log -1 --stat |
296 | | -
|
297 | | - git config --local --unset-all http.https://github.com/.extraheader || true |
298 | | - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git |
299 | | -
|
| 315 | + git remote set-url origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" |
300 | 316 | git push origin HEAD:main |
301 | 317 |
|
302 | | - - name: Create or update GitHub Release |
| 318 | + - name: Create/update release and upload bottles |
303 | 319 | uses: softprops/action-gh-release@v1 |
304 | 320 | with: |
305 | 321 | tag_name: ${{ steps.meta.outputs.tag }} |
306 | 322 | name: MFC bottles ${{ steps.meta.outputs.version }} |
307 | | - env: |
308 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
309 | | - |
310 | | - - name: Upload bottles to Release |
311 | | - uses: softprops/action-gh-release@v1 |
312 | | - with: |
313 | | - tag_name: ${{ steps.meta.outputs.tag }} |
314 | 323 | files: bottles/*.bottle.* |
| 324 | + fail_on_unmatched_files: true |
315 | 325 | env: |
316 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 326 | + GITHUB_TOKEN: ${{ github.token }} |
0 commit comments