Skip to content

Commit 4073a4a

Browse files
authored
Fix homebrew-release workflow for retags and fork URLs (#1155)
The URL/SHA update patterns only matched MFlowCode/MFC URLs, so the workflow failed when the formula temporarily pointed at a fork (e.g. during testing). Also, the commit step failed when the formula was already up to date (retag scenario). Broaden the URL patterns and skip the push gracefully when there are no changes.
1 parent c5493c1 commit 4073a4a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

.github/workflows/homebrew-release.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ jobs:
109109
110110
echo "Updating formula to v${VERSION}..."
111111
112-
# Update URL
113-
sed -i "s|url \"https://github.com/MFlowCode/MFC/archive/refs/tags/v[^\"]*\.tar\.gz\"|url \"https://github.com/MFlowCode/MFC/archive/refs/tags/v${VERSION}.tar.gz\"|" "$FORMULA"
112+
# Update URL (match any GitHub archive URL, not just MFlowCode/MFC,
113+
# in case the formula temporarily points at a fork during testing)
114+
sed -i "s|url \"https://github.com/[^\"]*/archive/[^\"]*\.tar\.gz\"|url \"https://github.com/MFlowCode/MFC/archive/refs/tags/v${VERSION}.tar.gz\"|" "$FORMULA"
114115
115116
# Update SHA256 (the one right after url, not bottle SHAs)
116117
# This uses awk to only update the first sha256 after the url line
117118
awk -v newsha="$SHA256" '
118-
/^ url "https:\/\/github.com\/MFlowCode\/MFC/ { found_url=1 }
119+
/^ url "https:\/\/github.com\// { found_url=1 }
119120
found_url && /^ sha256 "/ && !updated {
120121
sub(/sha256 "[^"]*"/, "sha256 \"" newsha "\"")
121122
updated=1
@@ -157,13 +158,16 @@ jobs:
157158
git config user.email "github-actions[bot]@users.noreply.github.com"
158159
159160
git add Formula/mfc.rb
160-
git commit -m "Update MFC to v${VERSION}"
161161
162-
echo "Pushing to homebrew-mfc..."
163-
git push origin main
164-
165-
echo "Successfully pushed formula update!"
166-
echo "The bottle.yml workflow in homebrew-mfc will now build bottles automatically."
162+
if git diff --cached --quiet; then
163+
echo "::notice::Formula already up to date for v${VERSION} — nothing to push."
164+
else
165+
git commit -m "Update MFC to v${VERSION}"
166+
echo "Pushing to homebrew-mfc..."
167+
git push origin main
168+
echo "Successfully pushed formula update!"
169+
echo "The bottle.yml workflow in homebrew-mfc will now build bottles automatically."
170+
fi
167171
168172
- name: Dry run summary
169173
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true' }}

0 commit comments

Comments
 (0)