From c5f035c2347174b5539f6dc8375ec87f513f72b7 Mon Sep 17 00:00:00 2001 From: Davy <95214375+thedavidweng@users.noreply.github.com> Date: Mon, 11 May 2026 15:30:48 -0700 Subject: [PATCH] feat: add Intel macOS (x64) CI/CD support via GitHub Actions - Add .github/workflows/release.yml with multi-platform build jobs - macOS x64 (macos-13 Intel runner): compile C binary + PyInstaller - macOS arm64 (macos-14 Apple Silicon runner) - Linux x64/arm64, Windows x64 - Auto-create GitHub Release with all platform binaries - Add darwin-x64, linux-x64, linux-arm64, win32-x64 to optionalDependencies so npm install works on all platforms --- .github/workflows/release.yml | 265 ++++++++++++++++++++++++++++++++++ npm/wechat-cli/package.json | 6 +- 2 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1866158 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,265 @@ +name: Build and Release Binaries + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g. 0.2.4)' + required: true + type: string + +permissions: + contents: write + +env: + PYTHON_VERSION: '3.11' + +jobs: + # ── macOS Intel (x64) ────────────────────────────────────────── + build-macos-x64: + runs-on: macos-13 # Intel runner + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: x64 + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Compile C binary for x86_64 + run: | + cc -O2 -arch x86_64 \ + -o wechat_cli/bin/find_all_keys_macos.x86_64 \ + wechat_cli/bin/find_all_keys_macos.c \ + -framework Foundation + chmod +x wechat_cli/bin/find_all_keys_macos.x86_64 + file wechat_cli/bin/find_all_keys_macos.x86_64 + + - name: Build PyInstaller binary + run: python npm/scripts/build.py darwin-x64 + + - name: Package platform tarball + run: | + cd npm/platforms/darwin-x64 + tar czf /tmp/wechat-cli-darwin-x64.tgz -C . bin/ + cd /tmp + echo "=== Contents ===" + tar tzf wechat-cli-darwin-x64.tgz + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: darwin-x64-binary + path: /tmp/wechat-cli-darwin-x64.tgz + + # ── macOS Apple Silicon (arm64) ──────────────────────────────── + build-macos-arm64: + runs-on: macos-14 # Apple Silicon runner + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Compile C binary for arm64 + run: | + cc -O2 -arch arm64 \ + -o wechat_cli/bin/find_all_keys_macos.arm64 \ + wechat_cli/bin/find_all_keys_macos.c \ + -framework Foundation + chmod +x wechat_cli/bin/find_all_keys_macos.arm64 + file wechat_cli/bin/find_all_keys_macos.arm64 + + - name: Build PyInstaller binary + run: python npm/scripts/build.py darwin-arm64 + + - name: Package platform tarball + run: | + cd npm/platforms/darwin-arm64 + tar czf /tmp/wechat-cli-darwin-arm64.tgz -C . bin/ + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: darwin-arm64-binary + path: /tmp/wechat-cli-darwin-arm64.tgz + + # ── Linux x64 ────────────────────────────────────────────────── + build-linux-x64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Build PyInstaller binary + run: python npm/scripts/build.py linux-x64 + + - name: Package platform tarball + run: | + cd npm/platforms/linux-x64 + tar czf /tmp/wechat-cli-linux-x64.tgz -C . bin/ + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: linux-x64-binary + path: /tmp/wechat-cli-linux-x64.tgz + + # ── Linux arm64 ──────────────────────────────────────────────── + build-linux-arm64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install cross-compilation toolchain + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Build PyInstaller binary (native, best-effort) + run: python npm/scripts/build.py linux-arm64 + continue-on-error: true + + - name: Package platform tarball + if: success() + run: | + cd npm/platforms/linux-arm64 + tar czf /tmp/wechat-cli-linux-arm64.tgz -C . bin/ + + - name: Upload artifact + if: success() + uses: actions/upload-artifact@v4 + with: + name: linux-arm64-binary + path: /tmp/wechat-cli-linux-arm64.tgz + + # ── Windows x64 ──────────────────────────────────────────────── + build-windows-x64: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Build PyInstaller binary + run: python npm/scripts/build.py win32-x64 + + - name: Package platform zip + run: | + cd npm/platforms/win32-x64 + Compress-Archive -Path bin/* -DestinationPath /tmp/wechat-cli-win32-x64.zip -Force + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: win32-x64-binary + path: /tmp/wechat-cli-win32-x64.zip + + # ── Create GitHub Release ────────────────────────────────────── + release: + needs: + - build-macos-x64 + - build-macos-arm64 + - build-linux-x64 + - build-linux-arm64 + - build-windows-x64 + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' + steps: + - uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: /tmp/artifacts + + - name: Determine version + id: ver + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT + else + echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + fi + + - name: List artifacts + run: find /tmp/artifacts -type f + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || format('v{0}', inputs.version) }} + name: wechat-cli ${{ steps.ver.outputs.VERSION }} + body: | + ## wechat-cli ${{ steps.ver.outputs.VERSION }} + + ### Platforms + | Platform | Arch | Package | + |----------|------|---------| + | macOS | x64 | `wechat-cli-darwin-x64.tgz` | + | macOS | arm64| `wechat-cli-darwin-arm64.tgz` | + | Linux | x64 | `wechat-cli-linux-x64.tgz` | + | Linux | arm64| `wechat-cli-linux-arm64.tgz` | + | Windows | x64 | `wechat-cli-win32-x64.zip` | + + ### npm install + ```bash + npm install -g @canghe_ai/wechat-cli@${{ steps.ver.outputs.VERSION }} + ``` + files: | + /tmp/artifacts/darwin-x64-binary/wechat-cli-darwin-x64.tgz + /tmp/artifacts/darwin-arm64-binary/wechat-cli-darwin-arm64.tgz + /tmp/artifacts/linux-x64-binary/wechat-cli-linux-x64.tgz + /tmp/artifacts/linux-arm64-binary/wechat-cli-linux-arm64.tgz + /tmp/artifacts/win32-x64-binary/wechat-cli-win32-x64.zip + draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/npm/wechat-cli/package.json b/npm/wechat-cli/package.json index 9743320..bd15c90 100644 --- a/npm/wechat-cli/package.json +++ b/npm/wechat-cli/package.json @@ -13,7 +13,11 @@ "install.js" ], "optionalDependencies": { - "@canghe_ai/wechat-cli-darwin-arm64": "0.2.4" + "@canghe_ai/wechat-cli-darwin-arm64": "0.2.4", + "@canghe_ai/wechat-cli-darwin-x64": "0.2.4", + "@canghe_ai/wechat-cli-linux-x64": "0.2.4", + "@canghe_ai/wechat-cli-linux-arm64": "0.2.4", + "@canghe_ai/wechat-cli-win32-x64": "0.2.4" }, "engines": { "node": ">=14"