Skip to content

Commit 4af4056

Browse files
committed
fix(ci): 优化 Windows 构建产物并修复更新器类型
- CI/CD 删除通用 exe,仅保留架构特定版本(x64/arm64) - 优化 Release 说明格式(表格化下载链接,简化说明) - 修复 electron-updater 类型导入和转换 - 移除 vite.config 中不必要的 external 配置
1 parent 332b436 commit 4af4056

3 files changed

Lines changed: 48 additions & 26 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,21 @@ jobs:
5555
env:
5656
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757

58+
- name: Remove universal exe (keep only arch-specific)
59+
if: matrix.platform == 'win'
60+
shell: bash
61+
run: |
62+
# 删除通用 exe,只保留带架构标识的
63+
find dist -name "*.exe" ! -name "*-x64.exe" ! -name "*-arm64.exe" -delete || true
64+
5865
- name: Upload artifacts
5966
uses: actions/upload-artifact@v4
6067
with:
6168
name: ${{ matrix.platform }}-build
6269
path: |
6370
dist/*.dmg
64-
dist/*.exe
71+
dist/*-x64.exe
72+
dist/*-arm64.exe
6573
if-no-files-found: ignore
6674

6775
release:
@@ -85,24 +93,24 @@ jobs:
8593
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
8694
generate_release_notes: true
8795
body: |
88-
## 📦 安装说明
89-
90-
### macOS
91-
- **Intel 芯片**: 下载 `PromptHub-x.x.x.dmg`
92-
- **Apple Silicon (M1/M2/M3)**: 下载 `PromptHub-x.x.x-arm64.dmg`
96+
## 📦 下载安装
9397
94-
> ⚠️ **首次启动提示**: 如果提示"无法打开",请在终端执行:
95-
> ```bash
96-
> sudo xattr -rd com.apple.quarantine /Applications/PromptHub.app
97-
> ```
98+
| 平台 | 芯片 | 下载 |
99+
|------|------|------|
100+
| macOS | Intel 芯片 | `PromptHub-${{ github.ref_name }}-x64.dmg` |
101+
| macOS | M 系列芯片 | `PromptHub-${{ github.ref_name }}-arm64.dmg` |
102+
| Windows | x64 | `PromptHub-Setup-${{ github.ref_name }}-x64.exe` |
98103
99-
### Windows
100-
- 下载 `PromptHub-x.x.x-setup.exe` 并运行安装
104+
### ⚠️ macOS 首次启动
105+
如果提示"无法打开"或"已损坏",请在终端执行:
106+
```bash
107+
sudo xattr -rd com.apple.quarantine /Applications/PromptHub.app
108+
```
101109
102110
---
103111
104-
## 🔄 更新内容
112+
## 🔄 本次更新
105113
106-
详细更新日志请查看 [CHANGELOG](https://github.com/legeling/PromptHub#-更新日志)
114+
详细更新日志请查看 [更新日志](https://github.com/legeling/PromptHub#-更新日志)
107115
env:
108116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/main/updater.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// @ts-ignore - electron-updater types will be available after pnpm install
2-
import { autoUpdater } from 'electron-updater';
1+
import { autoUpdater, UpdateInfo as ElectronUpdateInfo } from 'electron-updater';
32
import { BrowserWindow, ipcMain, app } from 'electron';
43

5-
// 类型定义
6-
interface UpdateInfo {
4+
// 简化的更新信息类型(用于 IPC 传输)
5+
interface SimpleUpdateInfo {
76
version: string;
87
releaseNotes?: string;
98
releaseDate?: string;
@@ -16,6 +15,21 @@ interface ProgressInfo {
1615
transferred: number;
1716
}
1817

18+
// 从 electron-updater 的 UpdateInfo 转换为简化格式
19+
function toSimpleInfo(info: ElectronUpdateInfo): SimpleUpdateInfo {
20+
let releaseNotes = '';
21+
if (typeof info.releaseNotes === 'string') {
22+
releaseNotes = info.releaseNotes;
23+
} else if (Array.isArray(info.releaseNotes)) {
24+
releaseNotes = info.releaseNotes.map(n => n.note || '').join('\n');
25+
}
26+
return {
27+
version: info.version,
28+
releaseNotes,
29+
releaseDate: info.releaseDate,
30+
};
31+
}
32+
1933
// 禁用自动下载,让用户选择
2034
autoUpdater.autoDownload = false;
2135
autoUpdater.autoInstallOnAppQuit = true;
@@ -24,7 +38,7 @@ let mainWindow: BrowserWindow | null = null;
2438

2539
export interface UpdateStatus {
2640
status: 'checking' | 'available' | 'not-available' | 'downloading' | 'downloaded' | 'error';
27-
info?: UpdateInfo;
41+
info?: SimpleUpdateInfo;
2842
progress?: ProgressInfo;
2943
error?: string;
3044
}
@@ -48,20 +62,20 @@ export function initUpdater(win: BrowserWindow) {
4862
});
4963

5064
// 有可用更新
51-
autoUpdater.on('update-available', (info: UpdateInfo) => {
65+
autoUpdater.on('update-available', (info) => {
5266
console.info('Update available:', info.version);
5367
sendStatusToWindow({
5468
status: 'available',
55-
info,
69+
info: toSimpleInfo(info),
5670
});
5771
});
5872

5973
// 没有可用更新
60-
autoUpdater.on('update-not-available', (info: UpdateInfo) => {
74+
autoUpdater.on('update-not-available', (info) => {
6175
console.info('Update not available, current version is latest');
6276
sendStatusToWindow({
6377
status: 'not-available',
64-
info,
78+
info: toSimpleInfo(info),
6579
});
6680
});
6781

@@ -75,11 +89,11 @@ export function initUpdater(win: BrowserWindow) {
7589
});
7690

7791
// 下载完成
78-
autoUpdater.on('update-downloaded', (info: UpdateInfo) => {
92+
autoUpdater.on('update-downloaded', (info) => {
7993
console.info('Update downloaded:', info.version);
8094
sendStatusToWindow({
8195
status: 'downloaded',
82-
info,
96+
info: toSimpleInfo(info),
8397
});
8498
});
8599
}

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default defineConfig({
1818
build: {
1919
outDir: 'out/main',
2020
rollupOptions: {
21-
external: ['better-sqlite3', 'electron-updater'],
21+
external: ['better-sqlite3'],
2222
},
2323
},
2424
},

0 commit comments

Comments
 (0)