Skip to content

Commit 9701ceb

Browse files
fix: handle empty homebrew-mumei repo in update-homebrew job
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 802d841 commit 9701ceb

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,15 @@ jobs:
181181
echo "${name}: ${sha}"
182182
done
183183
- name: Checkout homebrew-mumei
184-
uses: actions/checkout@v4
185-
with:
186-
repository: mumei-lang/homebrew-mumei
187-
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
188-
path: homebrew-mumei
184+
env:
185+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
186+
run: |
187+
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/mumei-lang/homebrew-mumei.git" homebrew-mumei 2>/dev/null || {
188+
mkdir -p homebrew-mumei
189+
cd homebrew-mumei
190+
git init -b main
191+
git remote add origin "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/mumei-lang/homebrew-mumei.git"
192+
}
189193
- name: Generate Homebrew Formula
190194
env:
191195
VERSION: ${{ github.ref_name }}
@@ -257,14 +261,18 @@ jobs:
257261
end
258262
end
259263
FORMULA_END
260-
- name: Create PR to homebrew-mumei
261-
uses: peter-evans/create-pull-request@v6
262-
with:
263-
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
264-
path: homebrew-mumei
265-
branch: update-formula/${{ github.ref_name }}
266-
title: "Update Mumei formula to ${{ github.ref_name }}"
267-
body: |
268-
Automated update from [mumei-lang/mumei release ${{ github.ref_name }}](https://github.com/mumei-lang/mumei/releases/tag/${{ github.ref_name }}).
269-
commit-message: "Update Mumei formula to ${{ github.ref_name }}"
270-
delete-branch: true
264+
- name: Push formula to homebrew-mumei
265+
env:
266+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
267+
run: |
268+
cd homebrew-mumei
269+
git config user.name "github-actions[bot]"
270+
git config user.email "github-actions[bot]@users.noreply.github.com"
271+
git add -A
272+
if git diff --cached --quiet; then
273+
echo "No changes to commit"
274+
exit 0
275+
fi
276+
git commit -m "Update Mumei formula to ${{ github.ref_name }}"
277+
# Push to main (handles both empty and existing repos)
278+
git push origin HEAD:main

0 commit comments

Comments
 (0)