mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
fix(release): publish macOS for Apple Silicon only
This commit is contained in:
1 parent
034f0b768f
commit
5f4eb4bb68
5 files changed
+37
-44
No files matched your search
@@ -62,18 +62,11 @@ jobs:
|
||||
|
||||
echo "Release version: $VERSION_TAG"
|
||||
|
||||
# macOS 构建需要分架构
|
||||
# better-sqlite3 等原生模块会通过 prebuild 下载对应架构的预编译二进制
|
||||
# macOS Desktop 仅发布 Apple Silicon 版本。onnxruntime-node 1.24+ 已停止提供
|
||||
# macOS x64 预编译二进制,继续生成 Intel 包会得到无法加载本地 embedding 的损坏产物。
|
||||
build-mac:
|
||||
needs: [prepare_release]
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-14 # 使用 ARM runner 交叉编译 x64
|
||||
arch: x64
|
||||
- os: macos-14 # Apple Silicon (arm64) 原生构建
|
||||
arch: arm64
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: macos-15
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
@@ -84,6 +77,15 @@ jobs:
|
||||
node-version: '24'
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Verify runner architecture
|
||||
shell: bash
|
||||
run: |
|
||||
ACTUAL_ARCH="$(node -p 'process.arch')"
|
||||
if [ "$ACTUAL_ARCH" != "arm64" ]; then
|
||||
echo "::error::Expected an arm64 runner, but Node.js is running as $ACTUAL_ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
@@ -96,41 +98,33 @@ jobs:
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-${{ matrix.arch }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
key: ${{ runner.os }}-arm64-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.arch }}-pnpm-store-
|
||||
${{ runner.os }}-arm64-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
echo "node-linker=hoisted" >> .npmrc
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
# Rust native parser:目标架构与 electron-builder --x64/--arm64 保持一致
|
||||
# Rust native parser:目标架构与 electron-builder --arm64 保持一致
|
||||
- name: Setup Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.arch == 'x64' && 'x86_64-apple-darwin' || 'aarch64-apple-darwin' }}
|
||||
targets: aarch64-apple-darwin
|
||||
|
||||
- name: Setup Rust cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: packages/parser-native
|
||||
key: ${{ matrix.arch }}
|
||||
key: arm64
|
||||
|
||||
# --target 必须直接传给 napi(不能用 -- 透传给 cargo),
|
||||
# 否则 napi 感知不到交叉编译,会按宿主架构(arm64)命名并构建产物
|
||||
- name: Build native parser (${{ matrix.arch }})
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${{ matrix.arch }}" == "x64" ]; then
|
||||
pnpm --filter @openchatlab/parser-native build --target x86_64-apple-darwin
|
||||
else
|
||||
pnpm --filter @openchatlab/parser-native build
|
||||
fi
|
||||
- name: Build native parser (arm64)
|
||||
run: pnpm --filter @openchatlab/parser-native build
|
||||
|
||||
- name: Verify native parser artifact
|
||||
shell: bash
|
||||
run: ls -la packages/parser-native/chatlab-parser-native.darwin-${{ matrix.arch }}.node
|
||||
run: ls -la packages/parser-native/chatlab-parser-native.darwin-arm64.node
|
||||
|
||||
- name: Inject version into app package.json
|
||||
shell: bash
|
||||
@@ -153,9 +147,9 @@ jobs:
|
||||
path: |
|
||||
~/Library/Caches/electron
|
||||
~/Library/Caches/electron-builder
|
||||
key: ${{ runner.os }}-${{ matrix.arch }}-electron-builder-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
key: ${{ runner.os }}-arm64-electron-builder-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.arch }}-electron-builder-
|
||||
${{ runner.os }}-arm64-electron-builder-
|
||||
|
||||
# macOS 签名和公证需要的 API Key 文件
|
||||
- name: Create Apple API Key File
|
||||
@@ -163,7 +157,7 @@ jobs:
|
||||
mkdir -p ~/private_keys
|
||||
echo "${{ secrets.APPLE_API_KEY }}" > ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8
|
||||
|
||||
- name: Build Electron app for macOS (${{ matrix.arch }})
|
||||
- name: Build Electron app for macOS (arm64)
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
# 代码签名
|
||||
@@ -177,16 +171,16 @@ jobs:
|
||||
UMAMI_ENDPOINT: ${{ secrets.UMAMI_ENDPOINT }}
|
||||
UMAMI_WEBSITE_ID: ${{ secrets.UMAMI_WEBSITE_ID }}
|
||||
working-directory: apps/desktop
|
||||
run: pnpm run build && pnpm exec electron-builder --mac --${{ matrix.arch }} --config electron-builder.yml -p never
|
||||
run: pnpm run build && pnpm exec electron-builder --mac --arm64 --config electron-builder.yml -p never
|
||||
|
||||
- name: Verify native parser in packaged app (${{ matrix.arch }})
|
||||
- name: Verify native parser in packaged app (arm64)
|
||||
shell: bash
|
||||
run: node scripts/check-desktop-native.mjs darwin-${{ matrix.arch }}
|
||||
run: node scripts/check-desktop-native.mjs darwin-arm64
|
||||
|
||||
- name: Upload macOS artifacts (${{ matrix.arch }})
|
||||
- name: Upload macOS artifacts (arm64)
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ChatLab-mac-${{ matrix.arch }}
|
||||
name: ChatLab-mac-arm64
|
||||
path: |
|
||||
apps/desktop/dist/*.dmg
|
||||
apps/desktop/dist/*.zip
|
||||
@@ -379,12 +373,6 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Download macOS artifacts (x64)
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ChatLab-mac-x64
|
||||
path: release-dist
|
||||
|
||||
- name: Download macOS artifacts (arm64)
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
@@ -436,7 +424,6 @@ jobs:
|
||||
echo "| Platform | File |"
|
||||
echo "|-----------------|-------------|"
|
||||
echo "| Mac (Apple Silicon) | [ChatLab-${VERSION_NUMBER}-arm64.dmg](https://github.com/ChatLab/ChatLab/releases/download/v${VERSION_NUMBER}/ChatLab-${VERSION_NUMBER}-arm64.dmg) |"
|
||||
echo "| Mac (Intel) | [ChatLab-${VERSION_NUMBER}-x64.dmg](https://github.com/ChatLab/ChatLab/releases/download/v${VERSION_NUMBER}/ChatLab-${VERSION_NUMBER}-x64.dmg) |"
|
||||
echo "| Windows | [ChatLab-${VERSION_NUMBER}-setup.exe](https://github.com/ChatLab/ChatLab/releases/download/v${VERSION_NUMBER}/ChatLab-${VERSION_NUMBER}-setup.exe) |"
|
||||
} > release_notes.md
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ files:
|
||||
- '!node_modules/@node-rs/jieba/idf.txt'
|
||||
- '!node_modules/@node-rs/jieba/dict.js'
|
||||
- '!node_modules/@node-rs/jieba/dict.d.ts'
|
||||
# onnxruntime-node 自带 darwin/linux/win32 全平台全架构原生二进制(合计 ~210M)。
|
||||
# onnxruntime-node 自带多个受支持平台/架构的原生二进制(合计约 210M,1.24+ 不再含 darwin/x64)。
|
||||
# 只保留当前构建目标 ${platform}/${arch} 一份,避免 mac 包含 Linux/Windows 二进制(反之亦然)。
|
||||
# 先排除整组 bin/napi-v6,再按目标平台/架构重新包含;electron-builder 后写规则覆盖先写规则。
|
||||
# ${platform} -> darwin/linux/win32,${arch} -> x64/arm64,正好匹配该包目录结构。
|
||||
# ${platform} -> darwin/linux/win32,${arch} -> x64/arm64,与该包目录结构一致。
|
||||
- '!node_modules/onnxruntime-node/bin/napi-v6/**'
|
||||
- 'node_modules/onnxruntime-node/bin/napi-v6/${platform}/${arch}/**'
|
||||
# parser-native 是 workspace 内的 Rust 包:只需要 index.js/index.d.ts/package.json 和 *.node,
|
||||
@@ -84,7 +84,7 @@ mac:
|
||||
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
|
||||
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
|
||||
target:
|
||||
# 架构由 CI 通过 --x64/--arm64 指定,避免在单个 job 里同时打双架构
|
||||
# 架构由 CI 通过 --arm64 指定;macOS Desktop 不再发布 Intel 版本
|
||||
- target: dmg
|
||||
- target: zip
|
||||
artifactName: ChatLab-${version}-${arch}.${ext}
|
||||
|
||||
@@ -10,6 +10,8 @@ ChatLab 提供 Desktop、CLI 和 Docker 三种安装方式。
|
||||
|
||||
前往 [ChatLab 官网](https://chatlab.fun) 或 [GitHub Releases](https://github.com/ChatLab/ChatLab/releases) 下载对应操作系统的安装包,双击安装即可。
|
||||
|
||||
macOS Desktop 目前仅支持搭载 Apple 芯片(M 系列)的 Mac。Intel Mac 用户可以使用下方的 CLI Web。
|
||||
|
||||
## CLI
|
||||
|
||||
CLI 需要 Node.js 20 或更高版本:
|
||||
|
||||
@@ -10,6 +10,8 @@ ChatLab is available as a Desktop app, CLI, or Docker image.
|
||||
|
||||
Download the installer for your operating system from the [ChatLab website](https://chatlab.fun) or [GitHub Releases](https://github.com/ChatLab/ChatLab/releases), then run it.
|
||||
|
||||
The macOS Desktop app currently supports Apple Silicon Macs only. Intel Mac users can use CLI Web below.
|
||||
|
||||
## CLI
|
||||
|
||||
The CLI requires Node.js 20 or newer:
|
||||
|
||||
@@ -10,6 +10,8 @@ ChatLab 提供 Desktop、CLI 和 Docker 三種安裝方式。
|
||||
|
||||
前往 [ChatLab 官網](https://chatlab.fun) 或 [GitHub Releases](https://github.com/ChatLab/ChatLab/releases) 下載對應作業系統的安裝程式,執行安裝即可。
|
||||
|
||||
macOS Desktop 目前僅支援搭載 Apple 晶片(M 系列)的 Mac。Intel Mac 使用者可以改用下方的 CLI Web。
|
||||
|
||||
## CLI
|
||||
|
||||
CLI 需要 Node.js 20 或更新版本:
|
||||
|
||||
Reference in new issue
Block a user