-
Notifications
You must be signed in to change notification settings - Fork 8
feat(brew): add Homebrew installation support #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: brew-update | ||
| run-name: "Update Homebrew formula for ${{ github.event.release.tag_name }}" | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| update-formula: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Extract version | ||
| id: ver | ||
| env: | ||
| TAG: ${{ github.event.release.tag_name }} | ||
| run: | | ||
| version="${TAG#v}" | ||
| echo "version=${version}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Download standalone tarball | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh release download "${{ github.event.release.tag_name }}" \ | ||
| --pattern "codexmate-${{ steps.ver.outputs.version }}-standalone.tar.gz" \ | ||
| --dir ./assets | ||
|
|
||
| - name: Compute SHA256 | ||
| id: sha | ||
| run: | | ||
| sha=$(sha256sum "./assets/codexmate-${{ steps.ver.outputs.version }}-standalone.tar.gz" | awk '{print $1}') | ||
| echo "sha256=${sha}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Checkout tap repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: SakuraByteCore/homebrew-codexmate | ||
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | ||
| ref: main | ||
|
|
||
| - name: Update formula | ||
| env: | ||
| VERSION: ${{ steps.ver.outputs.version }} | ||
| SHA256: ${{ steps.sha.outputs.sha256 }} | ||
| run: | | ||
| formula="Formula/codexmate.rb" | ||
|
|
||
| url="https://github.com/SakuraByteCore/codexmate/releases/download/v${VERSION}/codexmate-${VERSION}-standalone.tar.gz" | ||
|
|
||
| sed -i "s|^ url \".*\"| url \"${url}\"|" "$formula" | ||
| sed -i "s|^ sha256 \".*\"| sha256 \"${SHA256}\"|" "$formula" | ||
|
|
||
| echo "### Formula updated" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "- version: \`${VERSION}\`" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "- sha256: \`${SHA256}\`" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "- url: \`${url}\`" >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| cat "$formula" >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
|
Comment on lines
+44
to
+62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add verification after formula update to detect silent failures. The 🔍 Proposed fix to add verification - name: Update formula
env:
VERSION: ${{ steps.ver.outputs.version }}
SHA256: ${{ steps.sha.outputs.sha256 }}
run: |
formula="Formula/codexmate.rb"
url="https://github.com/SakuraByteCore/codexmate/releases/download/v${VERSION}/codexmate-${VERSION}-standalone.tar.gz"
sed -i "s|^ url \".*\"| url \"${url}\"|" "$formula"
sed -i "s|^ sha256 \".*\"| sha256 \"${SHA256}\"|" "$formula"
+
+ # Verify that sed actually updated the fields
+ if ! grep -q "url \"${url}\"" "$formula"; then
+ echo "::error::Failed to update url field in formula"
+ exit 1
+ fi
+ if ! grep -q "sha256 \"${SHA256}\"" "$formula"; then
+ echo "::error::Failed to update sha256 field in formula"
+ exit 1
+ fi
echo "### Formula updated" >> "$GITHUB_STEP_SUMMARY"
echo "- version: \`${VERSION}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- sha256: \`${SHA256}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- url: \`${url}\`" >> "$GITHUB_STEP_SUMMARY"
cat "$formula" >> "$GITHUB_STEP_SUMMARY"🤖 Prompt for AI Agents |
||
| - name: Commit and push | ||
| env: | ||
| VERSION: ${{ steps.ver.outputs.version }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add Formula/codexmate.rb | ||
| git diff --cached --quiet && echo "No changes to commit" && exit 0 | ||
| git commit -m "bump codexmate to v${VERSION}" | ||
| git push origin main | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for missing release asset.
If the standalone tarball hasn't been uploaded yet when this workflow runs (timing issue), or if the naming pattern doesn't match,
gh release downloadwill fail with a cryptic error. Consider adding explicit validation or a retry mechanism.🛡️ Proposed fix to add validation
- name: Download standalone tarball env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + # Wait briefly for asset upload to complete (if release webhook fires early) + sleep 5 + + # Verify asset exists before downloading + if ! gh release view "${{ github.event.release.tag_name }}" --json assets --jq '.assets[].name' | grep -q "codexmate-${{ steps.ver.outputs.version }}-standalone.tar.gz"; then + echo "::error::Release asset codexmate-${{ steps.ver.outputs.version }}-standalone.tar.gz not found" + echo "Available assets:" + gh release view "${{ github.event.release.tag_name }}" --json assets --jq '.assets[].name' + exit 1 + fi + gh release download "${{ github.event.release.tag_name }}" \ --pattern "codexmate-${{ steps.ver.outputs.version }}-standalone.tar.gz" \ --dir ./assets🤖 Prompt for AI Agents