From e022d17b0ab2c5f544b10723126d2b48c8baa28a Mon Sep 17 00:00:00 2001 From: ymkiux Date: Fri, 15 May 2026 14:29:40 +0800 Subject: [PATCH] feat(brew): add Homebrew tap and auto-update workflow --- .github/workflows/brew-update.yml | 72 +++++++++++++++++++++++++++++++ README.md | 11 ++++- README.zh.md | 11 ++++- 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/brew-update.yml diff --git a/.github/workflows/brew-update.yml b/.github/workflows/brew-update.yml new file mode 100644 index 00000000..3a73daa0 --- /dev/null +++ b/.github/workflows/brew-update.yml @@ -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" + + - 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 diff --git a/README.md b/README.md index c9aed4c2..602af3a3 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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: diff --git a/README.zh.md b/README.zh.md index 1c1df56d..2ad20dde 100644 --- a/README.zh.md +++ b/README.zh.md @@ -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) @@ -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 ...`),建议先安装: