Repository navigation
108 lines (92 loc) · 4.02 KB
/
Copy pathrelease.yml
File metadata and controls
108 lines (92 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Release
# 推送 v* 格式的 tag 时触发(如 git tag v1.0.0 && git push --tags)
on:
push:
tags:
- 'v*'
permissions:
contents: write # 创建 GitHub Release + 上传安装包 assets
jobs:
build:
name: Build & Release (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 60 # 防止 runner 长期排队导致 workflow 永不结束
strategy:
fail-fast: false # 一个平台失败不取消其他平台
matrix:
include:
- os: windows-latest
eb_flag: --win
- os: macos-latest # Apple Silicon (arm64);macos-13 Intel runner 供给严重不足
eb_flag: --mac
- os: ubuntu-latest
eb_flag: --linux
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build shared package
run: pnpm --filter @remotebridge/shared build
# Linux 需要 native 编译工具链
- name: Install build tools (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y python3 make g++
# 各平台均需编译适合本平台 + Electron 版本的 native 二进制(.cache/ 不提交到 git)
- name: Rebuild better-sqlite3 for Electron
working-directory: apps/desktop
shell: bash
run: |
npx @electron/rebuild@^3 -f -w better-sqlite3
node -e "
const f=require('fs'),p=require('path');
const src=p.resolve('node_modules/better-sqlite3/build/Release/better_sqlite3.node');
const dst=p.resolve('../../.cache/better_sqlite3.electron.node');
f.mkdirSync(p.dirname(dst),{recursive:true});
f.copyFileSync(src,dst);
console.log('Copied',f.statSync(dst).size,'bytes to',dst);
"
# 构建 Relay 服务器(bundle-relay.mjs 需要 apps/server/dist/)
- name: Build relay server
run: pnpm --filter @remotebridge/server build
# 将 Relay 打包成单文件嵌入桌面端安装包
- name: Bundle relay for desktop
working-directory: apps/desktop
run: node scripts/bundle-relay.mjs
# electron-vite build 生成 dist/main、dist/preload、dist/renderer
- name: Build Vite bundles
run: pnpm --filter @remotebridge/desktop exec electron-vite build
# electron-builder 打包并上传到 GitHub Release(Draft)
- name: Package & publish to GitHub Releases
working-directory: apps/desktop
run: npx electron-builder ${{ matrix.eb_flag }} --config=electron-builder.config.js --publish always
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 跳过代码签名:空字符串的 WIN_CSC_LINK / CSC_LINK 会被误认为路径报错,
# 需要签名时在 Settings → Secrets 配置后再添加回此处。
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
# 所有平台构建完毕(或超时/失败)后,将 Draft Release 正式发布
# 使用 if: !cancelled() 确保只要 workflow 未被手动取消就会执行
finalize:
name: Publish Release
needs: build
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
steps:
- name: 'Remind: use release-notes template'
run: |
echo "📝 Draft Release created for ${{ github.ref_name }}."
echo " Before publishing, paste the release description from release-notes/${{ github.ref_name }}.md"
echo " (or follow release-notes/TEMPLATE.md if this is the first release using the new format)."
- name: Mark release as published
continue-on-error: true # 若所有平台都失败导致 release 未创建,此步骤允许失败
run: gh release edit "${{ github.ref_name }}" --draft=false --repo Aswellle/RemoteBridge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}