Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

feat(desktop): support mac intel chip (#9084)

YuTengjing1a75f4a6b592
diff --git a/.github/scripts/pr-comment.js b/.github/scripts/pr-comment.js
index bb0c1a77d19..0775d7070d5 100644
--- a/.github/scripts/pr-comment.js
+++ b/.github/scripts/pr-comment.js
@@ -36,10 +36,19 @@ module.exports = async ({ github, context, releaseUrl, version, tag }) => {
// Generate combined download table
let assetTable = '| Platform | File | Size |\n| --- | --- | --- |\n';
- // Add macOS assets
+ // Add macOS assets with architecture detection
macAssets.forEach((asset) => {
const sizeInMB = (asset.size / (1024 * 1024)).toFixed(2);
- assetTable += `| macOS | [${asset.name}](${asset.browser_download_url}) | ${sizeInMB} MB |\n`;
+
+ // Detect architecture from filename
+ let architecture = '';
+ if (asset.name.includes('arm64')) {
+ architecture = ' (Apple Silicon)';
+ } else if (asset.name.includes('x64') || asset.name.includes('-mac.')) {
+ architecture = ' (Intel)';
+ }
+
+ assetTable += `| macOS${architecture} | [${asset.name}](${asset.browser_download_url}) | ${sizeInMB} MB |\n`;
});
// Add Windows assets
diff --git a/.github/workflows/desktop-pr-build.yml b/.github/workflows/desktop-pr-build.yml
index 1989b430f78..b5421fffbdf 100644
--- a/.github/workflows/desktop-pr-build.yml
+++ b/.github/workflows/desktop-pr-build.yml
@@ -32,18 +32,18 @@ jobs:
with:
node-version: 22
- - name: Setup pnpm
- uses: pnpm/action-setup@v2
+ - name: Install bun
+ uses: oven-sh/setup-bun@v1
with:
- version: 10
+ bun-version: ${{ secrets.BUN_VERSION }}
- name: Install deps
- run: pnpm install
+ run: bun i
env:
NODE_OPTIONS: --max-old-space-size=6144
- name: Lint
- run: pnpm run lint
+ run: bun run lint
env:
NODE_OPTIONS: --max-old-space-size=6144
@@ -93,7 +93,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- os: [macos-latest, windows-2025, ubuntu-latest]
+ os: [macos-latest, macos-13, windows-2025, ubuntu-latest]
steps:
- uses: actions/checkout@v5
with:
@@ -172,6 +172,27 @@ jobs:
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_PROJECT_ID }}
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_BASE_URL }}
+ # 处理 macOS latest-mac.yml 重命名 (避免多架构覆盖)
+ - name: Rename macOS latest-mac.yml for multi-architecture support
+ if: runner.os == 'macOS'
+ run: |
+ cd apps/desktop/release
+ if [ -f "latest-mac.yml" ]; then
+ # 根据运行环境检测架构
+ if [[ "${{ matrix.os }}" == *"arm64"* || "${{ matrix.os }}" == "macos-latest" ]]; then
+ ARCH_SUFFIX="arm"
+ else
+ ARCH_SUFFIX="intel"
+ fi
+
+ mv latest-mac.yml "latest-mac-${ARCH_SUFFIX}.yml"
+ echo "✅ Renamed latest-mac.yml to latest-mac-${ARCH_SUFFIX}.yml"
+ ls -la latest-mac-*.yml
+ else
+ echo "⚠️ latest-mac.yml not found, skipping rename"
+ ls -la latest*.yml || echo "No latest*.yml files found"
+ fi
+
# 上传构建产物
- name: Upload artifact
uses: actions/upload-artifact@v4
@@ -189,8 +210,62 @@ jobs:
apps/desktop/release/*.tar.gz*
retention-days: 5
- publish-pr:
+ # 合并 macOS 多架构 latest-mac.yml 文件
+ merge-mac-files:
needs: [build, version]
+ name: Merge macOS Release Files for PR
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 22
+
+ - name: Install required dependencies only
+ run: |
+ # 创建临时目录并安装依赖
+ mkdir -p temp-deps
+ cd temp-deps
+ npm init -y
+ npm install fs-extra yaml tsx
+ # 确保回到项目根目录
+ cd ${{ github.workspace }}
+
+ # 下载所有平台的构建产物
+ - name: Download artifacts
+ uses: actions/download-artifact@v4
+ with:
+ path: release
+ pattern: release-*
+ merge-multiple: true
+
+ # 列出下载的构建产物
+ - name: List downloaded artifacts
+ run: ls -R release
+
+ # 合并 macOS YAML 文件 (确保在项目根目录执行)
+ - name: Merge latest-mac.yml files
+ working-directory: ${{ github.workspace }}
+ run: NODE_PATH="${PWD}/temp-deps/node_modules" "${PWD}/temp-deps/node_modules/.bin/tsx" scripts/electronWorkflow/mergeMacReleaseFiles.ts ${{ needs.version.outputs.version }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ RELEASE_TAG: ${{ needs.version.outputs.version }}
+
+ # 上传合并后的构建产物
+ - name: Upload artifacts with merged macOS files
+ uses: actions/upload-artifact@v4
+ with:
+ name: merged-release-pr
+ path: release/
+ retention-days: 1
+
+ publish-pr:
+ needs: [merge-mac-files, version]
name: Publish PR Build
runs-on: ubuntu-latest
# Grant write permissions for creating release and commenting on PR
@@ -204,16 +279,15 @@ jobs:
with:
fetch-depth: 0
- # 下载所有平台的构建产物
- - name: Download artifacts
+ # 下载合并后的构建产物
+ - name: Download merged artifacts
uses: actions/download-artifact@v4
with:
+ name: merged-release-pr
path: release
- pattern: release-*
- merge-multiple: true
# 列出所有构建产物
- - name: List artifacts
+ - name: List final artifacts
run: ls -R release
# 生成PR发布描述
diff --git a/.github/workflows/release-desktop-beta.yml b/.github/workflows/release-desktop-beta.yml
index 3cdc5a6dfbc..806df2ae253 100644
--- a/.github/workflows/release-desktop-beta.yml
+++ b/.github/workflows/release-desktop-beta.yml
@@ -28,16 +28,16 @@ jobs:
with:
node-version: 22
- - name: Setup pnpm
- uses: pnpm/action-setup@v2
+ - name: Install bun
+ uses: oven-sh/setup-bun@v1
with:
- version: 10
+ bun-version: ${{ secrets.BUN_VERSION }}
- name: Install deps
- run: pnpm install
+ run: bun i
- name: Lint
- run: pnpm run lint
+ run: bun run lint
version:
name: Determine version
@@ -80,7 +80,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- os: [macos-latest, windows-2025, ubuntu-latest]
+ os: [macos-latest, macos-13, windows-2025, ubuntu-latest]
steps:
- uses: actions/checkout@v5
with:
@@ -91,14 +91,14 @@ jobs:
with:
node-version: 22
- - name: Setup pnpm
- uses: pnpm/action-setup@v2
+ - name: Install bun
+ uses: oven-sh/setup-bun@v1
with:
- version: 10
+ bun-version: ${{ secrets.BUN_VERSION }}
- # node-linker=hoisted 模式将可以确保 asar 压缩可用
+ # bun install 默认行为应该能确保 asar 压缩可用
- name: Install deps
- run: pnpm install --node-linker=hoisted
+ run: bun i
- name: Install deps on Desktop
run: npm run install-isolated --prefix=./apps/desktop
@@ -154,7 +154,28 @@ jobs:
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_BETA_DESKTOP_PROJECT_ID }}
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_BETA_DESKTOP_BASE_URL }}
- # 上传构建产物,移除了 zip 相关部分
+ # 处理 macOS latest-mac.yml 重命名 (避免多架构覆盖)
+ - name: Rename macOS latest-mac.yml for multi-architecture support
+ if: runner.os == 'macOS'
+ run: |
+ cd apps/desktop/release
+ if [ -f "latest-mac.yml" ]; then
+ # 根据运行环境检测架构
+ if [[ "${{ matrix.os }}" == *"arm64"* || "${{ matrix.os }}" == "macos-latest" ]]; then
+ ARCH_SUFFIX="arm"
+ else
+ ARCH_SUFFIX="intel"
+ fi
+
+ mv latest-mac.yml "latest-mac-${ARCH_SUFFIX}.yml"
+ echo "✅ Renamed latest-mac.yml to latest-mac-${ARCH_SUFFIX}.yml"
+ ls -la latest-mac-*.yml
+ else
+ echo "⚠️ latest-mac.yml not found, skipping rename"
+ ls -la latest*.yml || echo "No latest*.yml files found"
+ fi
+
+ # 上传构建产物 (工作流处理重命名,不依赖 electron-builder 钩子)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
@@ -171,17 +192,32 @@ jobs:
apps/desktop/release/*.tar.gz*
retention-days: 5
- # 正式版发布 job
- publish-release:
+ # 合并 macOS 多架构 latest-mac.yml 文件
+ merge-mac-files:
needs: [build, version]
- name: Publish Beta Release
+ name: Merge macOS Release Files
runs-on: ubuntu-latest
- # Grant write permission to contents for uploading release assets
permissions:
contents: write
- outputs:
- artifact_path: ${{ steps.set_path.outputs.path }}
steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 22
+
+ - name: Install required dependencies only
+ run: |
+ # 创建临时目录并安装依赖
+ mkdir -p temp-deps
+ cd temp-deps
+ npm init -y
+ npm install fs-extra yaml tsx
+ # 确保回到项目根目录
+ cd ${{ github.workspace }}
+
# 下载所有平台的构建产物
- name: Download artifacts
uses: actions/download-artifact@v4
@@ -190,11 +226,46 @@ jobs:
pattern: release-*
merge-multiple: true
+ # 列出下载的构建产物
+ - name: List downloaded artifacts
+ run: ls -R release
+
+ # 合并 macOS YAML 文件 (确保在项目根目录执行)
+ - name: Merge latest-mac.yml files
+ working-directory: ${{ github.workspace }}
+ run: NODE_PATH="${PWD}/temp-deps/node_modules" "${PWD}/temp-deps/node_modules/.bin/tsx" scripts/electronWorkflow/mergeMacReleaseFiles.ts ${{ github.event.release.tag_name }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
+
+ # 上传合并后的构建产物
+ - name: Upload artifacts with merged macOS files
+ uses: actions/upload-artifact@v4
+ with:
+ name: merged-release
+ path: release/
+ retention-days: 1
+
+ # 发布所有平台构建产物
+ publish-release:
+ needs: [merge-mac-files]
+ name: Publish Beta Release
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ # 下载合并后的构建产物
+ - name: Download merged artifacts
+ uses: actions/download-artifact@v4
+ with:
+ name: merged-release
+ path: release
+
# 列出所有构建产物
- - name: List artifacts
+ - name: List final artifacts
run: ls -R release
- # 将构建产物上传到现有 release
+ # 将构建产物上传到现有 release (现在包含合并后的 latest-mac.yml)
- name: Upload to Release
uses: softprops/action-gh-release@v1
with:
diff --git a/apps/desktop/electron-builder.js b/apps/desktop/electron-builder.js
index 9d1cf582a07..202e9c2e95c 100644
--- a/apps/desktop/electron-builder.js
+++ b/apps/desktop/electron-builder.js
@@ -1,12 +1,15 @@
const dotenv = require('dotenv');
+const os = require('node:os');
dotenv.config();
const packageJSON = require('./package.json');
const channel = process.env.UPDATE_CHANNEL;
+const arch = os.arch();
console.log(`🚄 Build Version ${packageJSON.version}, Channel: ${channel}`);
+console.log(`🏗️ Building for architecture: ${arch}`);
const isNightly = channel === 'nightly';
const isBeta = packageJSON.name.includes('beta');
@@ -87,12 +90,13 @@ const config = {
hardenedRuntime: true,
notarize: true,
target:
- // 降低构建时间,nightly 只打 arm64
+ // 降低构建时间,nightly 只打 dmg
+ // 根据当前机器架构只构建对应架构的包
isNightly
- ? [{ arch: ['arm64'], target: 'dmg' }]
+ ? [{ arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'dmg' }]
: [
- { arch: ['x64', 'arm64'], target: 'dmg' },
- { arch: ['x64', 'arm64'], target: 'zip' },
+ { arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'dmg' },
+ { arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'zip' },
],
},
npmRebuild: true,
diff --git a/scripts/electronWorkflow/mergeMacReleaseFiles.ts b/scripts/electronWorkflow/mergeMacReleaseFiles.ts
new file mode 100644
index 00000000000..4a1bc8e104b
--- /dev/null
+++ b/scripts/electronWorkflow/mergeMacReleaseFiles.ts
@@ -0,0 +1,207 @@
+/* eslint-disable unicorn/no-process-exit, unicorn/prefer-top-level-await */
+import fs from 'fs-extra';
+import path from 'node:path';
+import { parse, stringify } from 'yaml';
+
+interface LatestMacYml {
+ files: Array<{
+ sha512: string;
+ size: number;
+ url: string;
+ }>;
+ path: string;
+ releaseDate: string;
+ sha512: string;
+ version: string;
+}
+
+// 配置
+const RELEASE_TAG = process.env.RELEASE_TAG || process.argv[2];
+const FILE_NAME = 'latest-mac.yml';
+const RELEASE_DIR = path.resolve('release');
+
+// 验证环境变量和输入
+if (!RELEASE_TAG) {
+ console.error('❌ RELEASE_TAG environment variable or argument is required');
+ process.exit(1);
+}
+
+// 验证 release tag 格式
+if (!/^v?\d+\.\d+\.\d+/.test(RELEASE_TAG)) {
+ console.error(`❌ Invalid RELEASE_TAG format: ${RELEASE_TAG}. Expected format: v1.2.3`);
+ process.exit(1);
+}
+
+/**
+ * 检测 latest-mac.yml 文件的平台类型
+ */
+function detectPlatform(yamlContent: LatestMacYml): 'intel' | 'arm' | 'both' | 'none' {
+ const hasIntel = yamlContent.files.some((file) => file.url.includes('-x64.dmg'));
+ const hasArm = yamlContent.files.some((file) => file.url.includes('-arm64.dmg'));
+
+ if (hasIntel && hasArm) return 'both';
+ if (hasIntel && !hasArm) return 'intel';
+ if (!hasIntel && hasArm) return 'arm';
+ return 'none';
+}
+
+/**
+ * 合并两个 latest-mac.yml 文件
+ * @param intelContent Intel 平台的 YAML 内容
+ * @param armContent ARM 平台的 YAML 内容
+ */
+function mergeYamlFiles(intelContent: LatestMacYml, armContent: LatestMacYml): string {
+ // 以 Intel 为基础(保持兼容性)
+ const merged: LatestMacYml = {
+ ...intelContent,
+ files: [...intelContent.files, ...armContent.files],
+ };
+
+ // 使用 yaml 库生成,保持 sha512 在同一行
+ return stringify(merged, {
+ lineWidth: 0, // 不换行
+ });
+}
+
+// GitHub API functions removed since we're working with local files only
+
+/**
+ * 读取本地文件
+ */
+function readLocalFile(filePath: string): string | null {
+ try {
+ if (fs.existsSync(filePath)) {
+ const content = fs.readFileSync(filePath, 'utf8');
+ console.log(`✅ Read local file: ${filePath} (${content.length} chars)`);
+ return content;
+ }
+ console.log(`⚠️ Local file not found: ${filePath}`);
+ return null;
+ } catch (error) {
+ console.error(`❌ Error reading local file ${filePath}:`, error);
+ return null;
+ }
+}
+
+/**
+ * 写入本地文件
+ */
+function writeLocalFile(filePath: string, content: string): void {
+ try {
+ fs.writeFileSync(filePath, content, 'utf8');
+ console.log(`✅ Written local file: ${filePath} (${content.length} chars)`);
+ } catch (error) {
+ console.error(`❌ Error writing local file ${filePath}:`, error);
+ throw error;
+ }
+}
+
+/**
+ * 主函数
+ */
+async function main(): Promise<void> {
+ try {
+ console.log(`🚀 Starting macOS Release file merge for ${RELEASE_TAG}`);
+ console.log(`📁 Working directory: ${RELEASE_DIR}`);
+
+ // 1. 检查 release 目录下的所有文件
+ const releaseFiles = fs.readdirSync(RELEASE_DIR);
+ console.log(`📂 Files in release directory: ${releaseFiles.join(', ')}`);
+
+ // 2. 查找所有 latest-mac*.yml 文件
+ const macYmlFiles = releaseFiles.filter(
+ (f) => f.startsWith('latest-mac') && f.endsWith('.yml'),
+ );
+ console.log(`🔍 Found macOS YAML files: ${macYmlFiles.join(', ')}`);
+
+ if (macYmlFiles.length === 0) {
+ console.log('⚠️ No macOS YAML files found, skipping merge');
+ return;
+ }
+
+ // 3. 处理找到的文件,识别平台
+ const macFiles: Array<{
+ content: string;
+ filename: string;
+ platform: 'intel' | 'arm';
+ yaml: LatestMacYml;
+ }> = [];
+
+ for (const fileName of macYmlFiles) {
+ const filePath = path.join(RELEASE_DIR, fileName);
+ const content = readLocalFile(filePath);
+
+ if (!content) continue;
+
+ try {
+ const yamlContent = parse(content) as LatestMacYml;
+ const platform = detectPlatform(yamlContent);
+
+ if (platform === 'intel' || platform === 'arm') {
+ macFiles.push({ content, filename: fileName, platform, yaml: yamlContent });
+ console.log(`🔍 Detected ${platform} platform in ${fileName}`);
+ } else if (platform === 'both') {
+ console.log(`✅ Found already merged file: ${fileName}`);
+ // 如果已经是合并后的文件,直接复制为最终文件
+ writeLocalFile(path.join(RELEASE_DIR, FILE_NAME), content);
+ return;
+ } else {
+ console.log(`⚠️ Unknown platform type: ${platform} in ${fileName}`);
+ }
+ } catch (error) {
+ console.warn(`⚠️ Failed to parse ${fileName}:`, error);
+ }
+ }
+
+ // 4. 检查是否有两个不同平台的文件
+ const intelFiles = macFiles.filter((f) => f.platform === 'intel');
+ const armFiles = macFiles.filter((f) => f.platform === 'arm');
+
+ if (intelFiles.length === 0 && armFiles.length === 0) {
+ console.log('⚠️ No valid platform files found');
+ return;
+ }
+
+ if (intelFiles.length === 0) {
+ console.log('⚠️ No Intel files found, using ARM only');
+ writeLocalFile(path.join(RELEASE_DIR, FILE_NAME), armFiles[0].content);
+ return;
+ }
+
+ if (armFiles.length === 0) {
+ console.log('⚠️ No ARM files found, using Intel only');
+ writeLocalFile(path.join(RELEASE_DIR, FILE_NAME), intelFiles[0].content);
+ return;
+ }
+
+ // 5. 合并 Intel 和 ARM 文件
+ const intelFile = intelFiles[0];
+ const armFile = armFiles[0];
+
+ console.log(`🔄 Merging ${intelFile.filename} (Intel) and ${armFile.filename} (ARM)...`);
+ const mergedContent = mergeYamlFiles(intelFile.yaml, armFile.yaml);
+
+ // 6. 保存合并后的文件
+ const mergedFilePath = path.join(RELEASE_DIR, FILE_NAME);
+ writeLocalFile(mergedFilePath, mergedContent);
+
+ // 7. 验证合并结果
+ const mergedYaml = parse(mergedContent) as LatestMacYml;
+ const finalPlatform = detectPlatform(mergedYaml);
+
+ if (finalPlatform === 'both') {
+ console.log('✅ Successfully merged both Intel and ARM platforms');
+ console.log(`📊 Final file contains ${mergedYaml.files.length} files`);
+ } else {
+ console.warn(`⚠️ Merge result unexpected: ${finalPlatform}`);
+ }
+
+ console.log('🎉 Merge complete!');
+ } catch (error) {
+ console.error('❌ Error during merge:', error);
+ process.exit(1);
+ }
+}
+
+// 运行主函数
+void main();