Skip to content

Commit 54aa379

Browse files
authored
homebrew: fix brew style failure, sync formula to v5.5.0, preserve tap bottles (#1626)
* homebrew: fix new brew style offense, sync formula to v5.5.0, preserve tap bottles - Replace Formula["python@3.12"].opt_bin with formula_opt_bin("python@3.12"): Homebrew's new FormulaPathMethods cop (brew 2026-06-22) fails brew style on the old form, which broke Deploy Homebrew Tap and Homebrew Formula Test on the v5.5.0 release. - Bump the in-repo formula url/sha256 to v5.5.0 to match the tap, so the push-triggered tap deploy does not downgrade the tap back to v5.2.0. - Preserve the tap's existing bottle block in deploy-tap.yml when the release URL is unchanged, so formula-only pushes to master no longer delete bottles built for the current version. * deploy-tap: never downgrade the tap; drop redundant tag-event deploy - Push-to-master deploys previously copied the in-repo formula verbatim into the tap. Since homebrew-release.yml bumps the tap directly on releases, the repo copy lags behind and such a push would downgrade the tap and delete its bottles. The copy step now adopts the tap's url/sha256 whenever the tap pins a newer release, and the tap commit message uses the deployed version. - Remove the 'create' (tag) trigger: homebrew-release.yml already owns tag releases, so both workflows raced to push the tap on every tag, and this one put a strict brew audit on the release critical path (the v5.5.0 failure). Tag handling is kept for manual dispatch from a tag ref.
1 parent ebde16c commit 54aa379

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

‎.github/workflows/deploy-tap.yml‎

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ on:
1313
paths:
1414
- 'packaging/homebrew/mfc.rb'
1515
- 'packaging/homebrew/README.md'
16-
# Deploy to tap when a tag is created (no paths filter on tag creation)
17-
create:
16+
# Note: tag releases are deployed to the tap by homebrew-release.yml, not here.
1817
workflow_dispatch:
1918

2019
permissions:
@@ -24,7 +23,6 @@ jobs:
2423
deploy-tap:
2524
name: Audit and deploy formula
2625
runs-on: macos-14
27-
if: github.event_name != 'create' || github.event.ref_type == 'tag'
2826
permissions:
2927
contents: write
3028
pull-requests: write
@@ -44,12 +42,8 @@ jobs:
4442
EVENT_NAME="${{ github.event_name }}"
4543
REF_NAME="${{ github.ref_name }}"
4644
47-
if [[ "${EVENT_NAME}" == "create" ]]; then
48-
# Tag creation event
49-
VERSION="${REF_NAME#v}"
50-
URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${VERSION}.tar.gz"
51-
elif [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then
52-
# Tag push event
45+
if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then
46+
# Manual dispatch from a tag ref
5347
VERSION="${REF_NAME#v}"
5448
URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${VERSION}.tar.gz"
5549
else
@@ -71,7 +65,7 @@ jobs:
7165
fi
7266
7367
- name: Update formula (for tag events)
74-
if: github.event_name == 'create' || github.ref_type == 'tag'
68+
if: github.ref_type == 'tag'
7569
run: |
7670
/usr/bin/sed -i '' "s@^ url \".*\"@ url \"${{ steps.meta.outputs.url }}\"@" packaging/homebrew/mfc.rb
7771
/usr/bin/sed -i '' "s@^ sha256 \".*\"@ sha256 \"${{ steps.meta.outputs.sha256 }}\"@" packaging/homebrew/mfc.rb
@@ -110,11 +104,41 @@ jobs:
110104
fi
111105
112106
- name: Copy formula and README into tap
107+
id: merge
113108
if: github.event_name != 'pull_request'
114109
run: |
110+
set -euo pipefail
115111
mkdir -p tap-repo/Formula
116-
cp packaging/homebrew/mfc.rb tap-repo/Formula/mfc.rb
112+
SRC=packaging/homebrew/mfc.rb
113+
TAP=tap-repo/Formula/mfc.rb
114+
get_ver() { grep -Eo '/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "$1" | head -n 1 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'; }
115+
MERGED="$(mktemp)"
116+
cp "${SRC}" "${MERGED}"
117+
if [[ -f "${TAP}" ]]; then
118+
SRC_VER="$(get_ver "${SRC}" || true)"
119+
TAP_VER="$(get_ver "${TAP}" || true)"
120+
# homebrew-release.yml bumps the tap directly on releases, so the in-repo
121+
# formula can lag behind. Never downgrade: if the tap pins a newer release,
122+
# keep the tap's url/sha256 while still syncing the rest of the formula.
123+
if [[ -n "${SRC_VER}" && -n "${TAP_VER}" && "${SRC_VER}" != "${TAP_VER}" ]] \
124+
&& [[ "$(printf '%s\n%s\n' "${SRC_VER}" "${TAP_VER}" | sort -V | tail -n 1)" == "${TAP_VER}" ]]; then
125+
TAP_URL_LINE="$(grep -E '^ url ' "${TAP}")"
126+
TAP_SHA_LINE="$(grep -E '^ sha256 "' "${TAP}" | head -n 1)"
127+
awk -v url="${TAP_URL_LINE}" -v sha="${TAP_SHA_LINE}" \
128+
'/^ url / { print url; next } /^ sha256 "/ { print sha; next } { print }' \
129+
"${SRC}" > "${MERGED}"
130+
fi
131+
# If the pinned release is unchanged, keep the tap's existing bottle block so a
132+
# formula-only push to master doesn't delete bottles already built for this version.
133+
if [[ "$(grep -E '^ url ' "${MERGED}")" == "$(grep -E '^ url ' "${TAP}")" ]] && grep -q '^ bottle do' "${TAP}"; then
134+
awk '/^ bottle do/,/^ end$/' "${TAP}" > /tmp/bottle.block
135+
awk '{ print } /^ head / { print ""; while ((getline line < "/tmp/bottle.block") > 0) print line }' \
136+
"${MERGED}" > "${MERGED}.tmp" && mv "${MERGED}.tmp" "${MERGED}"
137+
fi
138+
fi
139+
mv "${MERGED}" "${TAP}"
117140
cp packaging/homebrew/README.md tap-repo/README.md
141+
echo "version=$(get_ver "${TAP}" || true)" >> "$GITHUB_OUTPUT"
118142
119143
- name: Commit & push if changed
120144
if: github.event_name != 'pull_request'
@@ -128,6 +152,6 @@ jobs:
128152
exit 0
129153
fi
130154
git -c user.name="github-actions[bot]" -c user.email="github-actions[bot]@users.noreply.github.com" \
131-
commit -m "mfc: v${{ steps.meta.outputs.version }}"
155+
commit -m "mfc: v${{ steps.merge.outputs.version || steps.meta.outputs.version }}"
132156
git push origin HEAD:main
133157

‎packaging/homebrew/mfc.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
class Mfc < Formula
77
desc "Exascale multiphase/multiphysics compressible flow solver"
88
homepage "https://mflowcode.github.io/"
9-
url "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.2.0.tar.gz"
10-
sha256 "aaee855302950cb6bd8497170a6737214ed9a47ad3d109258f5b27ee2b78fe3d"
9+
url "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.5.0.tar.gz"
10+
sha256 "05499f28291654ee5cc7f4344c85b5b12707e43e8408e7a28b96e43020e42959"
1111
license "MIT"
1212
head "https://github.com/MFlowCode/MFC.git", branch: "master"
1313

@@ -28,7 +28,7 @@ class Mfc < Formula
2828
def install
2929
# Create Python virtual environment inside libexec (inside Cellar for proper bottling)
3030
venv = libexec/"venv"
31-
system Formula["python@3.12"].opt_bin/"python3.12", "-m", "venv", venv
31+
system formula_opt_bin("python@3.12")/"python3.12", "-m", "venv", venv
3232
system venv/"bin/pip", "install", "--upgrade",
3333
"pip", "setuptools", "wheel",
3434
"setuptools-scm",

0 commit comments

Comments
 (0)