Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/brew-update.yml
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
Comment on lines +23 to +29
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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 download will 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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/brew-update.yml around lines 23 - 29, The workflow step
"Download standalone tarball" currently runs gh release download with the
pattern "codexmate-${{ steps.ver.outputs.version }}-standalone.tar.gz" and can
fail cryptically if the asset is missing or misnamed; update the step to first
validate the asset exists (e.g., use gh release view or gh api to list assets
for github.event.release.tag_name and check for the exact filename using
steps.ver.outputs.version) and if not found implement a short retry loop with
backoff (or fail with a clear message listing available asset names) before
calling gh release download; ensure the updated logic still uses GH_TOKEN and
preserves the download behavior when the asset is present.


- 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add verification after formula update to detect silent failures.

The sed patterns assume exactly 2 spaces of indentation (^ url and ^ sha256). If the formula format uses tabs or different spacing, the patterns won't match and sed -i will silently succeed without making changes. This could result in committing an unchanged formula.

🔍 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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/brew-update.yml around lines 44 - 62, The sed replacements
for url and sha256 in the "Update formula" step can silently fail due to varying
indentation; after running sed on the formula variable, verify the update
succeeded by checking the file contains the expected url and SHA256 (e.g., grep
or grep -q for the constructed url variable and the SHA256 value) and exit
non‑zero with a clear message if either check fails; update the step to perform
those verification checks using the existing VERSION, SHA256, url, and formula
variables so the workflow fails fast instead of committing an unchanged Formula.

- 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
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Version](https://img.shields.io/npm/v/codexmate?label=version&style=flat)](https://www.npmjs.com/package/codexmate)
[![Build](https://img.shields.io/github/actions/workflow/status/SakuraByteCore/codexmate/release.yml?label=build&style=flat)](https://github.com/SakuraByteCore/codexmate/actions/workflows/release.yml)
[![Downloads](https://img.shields.io/npm/dt/codexmate?label=downloads&style=flat)](https://www.npmjs.com/package/codexmate)
[![Install](https://img.shields.io/badge/install-curl%20%7C%20npm-0A0?style=flat)](#install-via-curl-standalone)
[![Install](https://img.shields.io/badge/install-brew%20%7C%20curl%20%7C%20npm-0A0?style=flat)](#install-via-homebrew-macos--linux)
[![Platform](https://img.shields.io/badge/platform-Termux%20%7C%20Linux%20%7C%20macOS%20%7C%20Windows-555?style=flat)](#quick-start)
[![Node](https://img.shields.io/node/v/codexmate?label=Node.js&style=flat&logo=node.js&logoColor=white)](https://nodejs.org/)
[![License](https://img.shields.io/npm/l/codexmate?label=license&style=flat)](LICENSE)
Expand Down Expand Up @@ -192,6 +192,15 @@ Installs to `~/.codexmate`, symlinks to `~/.local/bin/codexmate`, and auto-adds
| `CODEXMATE_INSTALL_DIR` | `~/.codexmate` | Installation directory |
| `CODEXMATE_BIN_DIR` | `~/.local/bin` | Symlink directory |

### Install via Homebrew (macOS / Linux)

```bash
brew tap SakuraByteCore/codexmate
brew install codexmate
```

Requires [Node.js](https://nodejs.org/) (`brew install node` if not present).

### Install Codex CLI / Claude Code CLI (optional)

Codex Mate can pass through to the official CLIs (e.g. `codexmate codex ...`). Install them first:
Expand Down
11 changes: 10 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Version](https://img.shields.io/npm/v/codexmate?label=version&style=flat)](https://www.npmjs.com/package/codexmate)
[![Build](https://img.shields.io/github/actions/workflow/status/SakuraByteCore/codexmate/release.yml?label=build&style=flat)](https://github.com/SakuraByteCore/codexmate/actions/workflows/release.yml)
[![Downloads](https://img.shields.io/npm/dt/codexmate?label=downloads&style=flat)](https://www.npmjs.com/package/codexmate)
[![Install](https://img.shields.io/badge/install-curl%20%7C%20npm-0A0?style=flat)](#curl-一键安装独立包无需-npm)
[![Install](https://img.shields.io/badge/install-brew%20%7C%20curl%20%7C%20npm-0A0?style=flat)](#homebrew-安装macos--linux)
[![Platform](https://img.shields.io/badge/platform-Termux%20%7C%20Linux%20%7C%20macOS%20%7C%20Windows-555?style=flat)](#快速开始)
[![Node](https://img.shields.io/node/v/codexmate?label=Node.js&style=flat&logo=node.js&logoColor=white)](https://nodejs.org/)
[![License](https://img.shields.io/npm/l/codexmate?label=license&style=flat)](LICENSE)
Expand Down Expand Up @@ -195,6 +195,15 @@ curl -fsSL https://raw.githubusercontent.com/SakuraByteCore/codexmate/main/scrip
| `CODEXMATE_INSTALL_DIR` | `~/.codexmate` | 安装目录 |
| `CODEXMATE_BIN_DIR` | `~/.local/bin` | 软链接目录 |

### Homebrew 安装(macOS / Linux)

```bash
brew tap SakuraByteCore/codexmate
brew install codexmate
```

需要 [Node.js](https://nodejs.org/)(如未安装可执行 `brew install node`)。

### 安装 Codex CLI / Claude Code / Gemini CLI / CodeBuddy Code(可选)

Codex Mate 支持透传调用官方 CLI(例如 `codexmate codex ...`),建议先安装:
Expand Down
Loading