@@ -24,40 +24,29 @@ jobs:
2424
2525 - name : Set up Homebrew
2626 uses : Homebrew/actions/setup-homebrew@master
27-
28- - name : Ensure no conflicting taps provide mfc
27+
28+ # IMPORTANT: do NOT untap mflowcode/mfc in this job. setup-homebrew manages it and
29+ # its post-cleanup expects the tap directory to exist.
30+ - name : Ensure no leftover local tap
2931 shell : bash
3032 run : |
3133 set -euo pipefail
32- brew untap mflowcode/mfc >/dev/null 2>&1 || true
3334 brew untap mflowcode/local >/dev/null 2>&1 || true
34-
35- - name : Test tarball download
36- run : |
37- curl -I "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz"
38- curl -L "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" | shasum -a 256
3935
4036 - name : Determine version and root URL (from checked-out formula)
4137 id : meta
38+ shell : bash
4239 run : |
4340 set -euo pipefail
4441 FORMULA="Formula/mfc.rb"
45-
4642 URL="$(
4743 grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "${FORMULA}" \
4844 | tail -n 1
4945 )"
50-
51- if [[ -z "${URL}" ]]; then
52- echo "Could not extract release tarball URL from ${FORMULA}" >&2
53- exit 1
54- fi
46+ [[ -n "${URL}" ]]
5547
5648 VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')"
57- if [[ -z "${VERSION}" ]]; then
58- echo "Could not parse version from URL: ${URL}" >&2
59- exit 1
60- fi
49+ [[ -n "${VERSION}" ]]
6150
6251 TAG="mfc-${VERSION}"
6352 ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}"
@@ -71,62 +60,41 @@ jobs:
7160 echo "Release tag: ${TAG}"
7261 echo "Bottle root_url: ${ROOT_URL}"
7362
74- - name : Create temp tap with checked-out formula
75- run : |
76- set -euo pipefail
77-
78- # brew tap-new needs git identity sometimes
79- git config --global user.email "github-actions[bot]@users.noreply.github.com"
80- git config --global user.name "github-actions[bot]"
81-
82- # Create a local tap and copy the formula into Homebrew's tap location
83- brew tap-new mflowcode/local
84- TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local"
85- mkdir -p "${TAP_DIR}/Formula"
86- cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb"
87-
88- echo "Temp tap formula:"
89- ls -la "${TAP_DIR}/Formula/mfc.rb"
90-
91- - name : Install formula with --build-bottle (temp tap)
63+ - name : Install formula with --build-bottle (tap formula)
64+ shell : bash
9265 run : |
9366 set -euo pipefail
94-
9567 echo "Installing mfc with --build-bottle (allowing non-fatal dylib fixup failures)..."
9668
97- # Homebrew may exit non-zero due to dylib ID fixup issues in Python wheels,
98- # even though the formula actually installed correctly. Treat that as
99- # non-fatal as long as the formula is present.
10069 set +e
101- brew install --build-bottle mflowcode/local /mfc 2>&1 | tee /tmp/brew-install.log
70+ brew install --build-bottle mflowcode/mfc /mfc 2>&1 | tee /tmp/brew-install.log
10271 brew_exit_code=$?
10372 set -e
10473
105- if brew list mflowcode/local /mfc &>/dev/null; then
74+ if brew list mflowcode/mfc /mfc &>/dev/null; then
10675 echo "✅ mfc installed successfully (ignoring dylib fixup warnings)"
10776 else
10877 echo "❌ mfc installation failed; propagating brew exit code"
10978 exit $brew_exit_code
11079 fi
11180
11281 - name : Run Sod shock tube test case
82+ shell : bash
11383 run : |
11484 set -euo pipefail
11585 echo "Running a simple test case (1D Sod shock tube) on ${{ matrix.os }}..."
116-
117- TESTDIR=$(mktemp -d)
118- cp "$(brew --prefix mflowcode/local/mfc)/examples/1D_sodshocktube/case.py" "$TESTDIR/"
119-
86+ TESTDIR="$(mktemp -d)"
87+ cp "$(brew --prefix mflowcode/mfc/mfc)/examples/1D_sodshocktube/case.py" "$TESTDIR/"
12088 cd "$TESTDIR"
12189 mfc case.py -j 1
122-
12390 test -d "$TESTDIR/silo_hdf5"
12491 echo "✅ Test case ran successfully and produced output"
12592
12693 - name : Basic installation verification
94+ shell : bash
12795 run : |
12896 set -euo pipefail
129- PREFIX="$(brew --prefix mflowcode/local /mfc)"
97+ PREFIX="$(brew --prefix mflowcode/mfc /mfc)"
13098
13199 echo "1. Checking binaries..."
132100 test -x "${PREFIX}/bin/pre_process"
@@ -149,10 +117,11 @@ jobs:
149117
150118 echo "✅ All verification checks passed on ${{ matrix.os }}"
151119
152- - name : Build bottle (temp tap formula)
120+ - name : Build bottle (tap formula)
121+ shell : bash
153122 run : |
154123 set -euo pipefail
155- brew bottle --root-url="${{ steps.meta.outputs.root_url }}" --json mflowcode/local /mfc
124+ brew bottle --root-url="${{ steps.meta.outputs.root_url }}" --json mflowcode/mfc /mfc
156125 ls -1 *.bottle.*
157126
158127 - name : Upload bottle artifacts
@@ -178,25 +147,18 @@ jobs:
178147
179148 - name : Determine version and root URL (from checked-out formula)
180149 id : meta
150+ shell : bash
181151 run : |
182152 set -euo pipefail
183153 FORMULA="Formula/mfc.rb"
184-
185154 URL="$(
186155 grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "${FORMULA}" \
187156 | tail -n 1
188157 )"
189-
190- if [[ -z "${URL}" ]]; then
191- echo "Could not extract release tarball URL from ${FORMULA}" >&2
192- exit 1
193- fi
158+ [[ -n "${URL}" ]]
194159
195160 VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')"
196- if [[ -z "${VERSION}" ]]; then
197- echo "Could not parse version from URL: ${URL}" >&2
198- exit 1
199- fi
161+ [[ -n "${VERSION}" ]]
200162
201163 TAG="mfc-${VERSION}"
202164 ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}"
@@ -206,6 +168,7 @@ jobs:
206168 echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT"
207169
208170 - name : Configure git for bottle merge
171+ shell : bash
209172 run : |
210173 set -euo pipefail
211174 git config --global user.email "github-actions[bot]@users.noreply.github.com"
@@ -217,78 +180,55 @@ jobs:
217180 path : bottles
218181
219182 - name : Flatten bottle directory
183+ shell : bash
220184 run : |
221185 set -euo pipefail
222186 echo "Before flattening:"
223187 find bottles -name '*.bottle.*' -type f
224-
225188 find bottles -mindepth 2 -name '*.bottle.*' -type f -exec mv {} bottles/ \;
226-
227189 echo ""
228190 echo "After flattening:"
229191 ls -1 bottles/*.bottle.*
230192
231193 - name : Rename bottles for GitHub release
194+ shell : bash
232195 run : |
233196 set -euo pipefail
234197 echo "Renaming bottles (mfc-- → mfc-)..."
235-
236198 for file in bottles/mfc--*.bottle.*; do
237199 if [[ -f "$file" ]]; then
238200 newname=$(echo "$file" | sed 's/mfc--/mfc-/')
239201 mv "$file" "$newname"
240202 echo " $file → $newname"
241203 fi
242204 done
243-
244205 echo ""
245206 echo "Bottles ready for upload:"
246207 ls -1 bottles/*.bottle.*
247208
248- - name : Ensure no conflicting taps provide mfc (merge job)
249- shell : bash
250- run : |
251- set -euo pipefail
252- brew untap mflowcode/mfc >/dev/null 2>&1 || true
253- brew untap mflowcode/local >/dev/null 2>&1 || true
254-
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]"
261-
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"
266-
267- brew info mflowcode/local/mfc
268-
269209 - name : Merge bottle metadata into formula
270210 id : merge
271211 shell : bash
272212 run : |
273213 set -euo pipefail
274-
214+ shopt -s nullglob
275215 JSON_BOTTLES=(bottles/*.bottle*.json)
276- if [[ ! -e "${ JSON_BOTTLES[0]}" ]] ; then
216+ if (( ${# JSON_BOTTLES[@]} == 0 )) ; then
277217 echo "No bottle metadata (*.bottle*.json) found in bottles/"
278218 ls -la bottles/
279219 exit 1
280220 fi
281-
282- TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local"
283-
221+
284222 echo "Merging bottle metadata from:"
285223 printf '%s\n' "${JSON_BOTTLES[@]}"
286-
224+
287225 brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}"
288-
289- # Copy the updated formula back into this checkout so git add works here
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"
290230 cp "${TAP_DIR}/Formula/mfc.rb" Formula/mfc.rb
291-
231+
292232 if git diff --quiet -- Formula/mfc.rb; then
293233 echo "bottle_updated=false" >> "$GITHUB_OUTPUT"
294234 else
@@ -301,12 +241,8 @@ jobs:
301241 run : |
302242 set -euo pipefail
303243 git add Formula/mfc.rb
304- if git diff --cached --quiet; then
305- echo "No changes staged; skipping commit."
306- exit 0
307- fi
308244 git commit -m "mfc: bottles for v${{ steps.meta.outputs.version }}"
309-
245+
310246 - name : Push bottle updates if changed
311247 if : steps.merge.outputs.bottle_updated == 'true'
312248 shell : bash
0 commit comments