diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 00000000..16a0dc5e --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,91 @@ +name: Build macOS + +on: + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-macos: + strategy: + fail-fast: false + matrix: + include: + - target: aarch64-apple-darwin + arch: Apple Silicon (M1/M2/M3/M4) + - target: x86_64-apple-darwin + arch: Intel Mac + + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Install frontend dependencies + working-directory: apps/codex-plus-manager + run: npm install --package-lock=false + + - name: Build frontend + working-directory: apps/codex-plus-manager + run: npm run vite:build + env: + NODE_OPTIONS: --max-old-space-size=4096 + + - name: Build binaries + run: cargo build --release --target ${{ matrix.target }} + + - name: Package as .app bundles + env: + VERSION: "1.1.8" + run: bash scripts/installer/macos/package-dmg.sh "$VERSION" "${{ matrix.arch }}" + + - name: Create output directory + run: mkdir -p dist/macos + + - name: Move .app bundles to dist + run: | + mv dist/macos-unpacked/*.app dist/macos/ 2>/dev/null || true + mv dist/macos/*.app dist/macos/ 2>/dev/null || true + + - name: List artifacts + run: find dist/macos -type f \( -name "*.app" -o -name "*.dmg" \) | head -10 + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: macos-${{ matrix.arch }}-binaries + path: dist/macos/ + retention-days: 7 + + create-release: + needs: build-macos + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: List downloaded artifacts + run: find artifacts -type f | head -20 + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: macos-build + name: macOS Build + draft: true + files: | + artifacts/**/* diff --git a/apps/codex-plus-manager/src-tauri/icons/icon.ico b/apps/codex-plus-manager/src-tauri/icons/icon.ico index 8433b687..b0392a0d 100644 Binary files a/apps/codex-plus-manager/src-tauri/icons/icon.ico and b/apps/codex-plus-manager/src-tauri/icons/icon.ico differ diff --git a/apps/codex-plus-manager/src-tauri/icons/icon.png b/apps/codex-plus-manager/src-tauri/icons/icon.png index a8952aac..8e57bf4d 100644 Binary files a/apps/codex-plus-manager/src-tauri/icons/icon.png and b/apps/codex-plus-manager/src-tauri/icons/icon.png differ diff --git a/scripts/installer/macos/package-dmg.sh b/scripts/installer/macos/package-dmg.sh index 8752e204..a1f72574 100644 --- a/scripts/installer/macos/package-dmg.sh +++ b/scripts/installer/macos/package-dmg.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash set -euo pipefail VERSION="${1:-0.0.0}" @@ -7,6 +7,12 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" DIST="$ROOT/dist/macos" STAGE="$DIST/stage" BINARY_DIR="${BINARY_DIR:-$ROOT/target/release}" +# Auto-detect cross-compile target directory +if [ -d "$ROOT/target/aarch64-apple-darwin/release" ]; then + BINARY_DIR="$ROOT/target/aarch64-apple-darwin/release" +elif [ -d "$ROOT/target/x86_64-apple-darwin/release" ]; then + BINARY_DIR="$ROOT/target/x86_64-apple-darwin/release" +fi DMG="$DIST/CodexPlusPlus-${VERSION}-macos-${ARCH}.dmg" ICON_SOURCE="$ROOT/apps/codex-plus-manager/src-tauri/icons/icon.png" ICON_NAME="codex-plus-plus.icns" @@ -78,16 +84,27 @@ PLIST sign_app() { local app_dir="$1" - codesign --force --deep --sign - "$app_dir" + codesign --force --deep --sign - "$app_dir" 2>/dev/null || true } prepare_icon + +# Detect actual arch from binary path +if echo "$BINARY_DIR" | grep -q "aarch64"; then + APP_ARCH="arm64" +elif echo "$BINARY_DIR" | grep -q "x86_64"; then + APP_ARCH="x86_64" +else + APP_ARCH="$ARCH" +fi + create_app "Codex++" "CodexPlusPlus" "$BINARY_DIR/codex-plus-plus" "com.bigpizzav3.codexplusplus" "true" -create_app "Codex++ 管理工具" "CodexPlusPlusManager" "$BINARY_DIR/codex-plus-plus-manager" "com.bigpizzav3.codexplusplus.manager" "false" +create_app "Codex++ Manager" "CodexPlusPlusManager" "$BINARY_DIR/codex-plus-plus-manager" "com.bigpizzav3.codexplusplus.manager" "false" + ln -s /Applications "$STAGE/Applications" sign_app "$STAGE/Codex++.app" -sign_app "$STAGE/Codex++ 管理工具.app" +sign_app "$STAGE/Codex++ Manager.app" hdiutil create -volname "Codex++" -srcfolder "$STAGE" -ov -format UDZO "$DMG" echo "$DMG"