forked from 21st-dev/1code
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (128 loc) · 4.24 KB
/
build-release.yml
File metadata and controls
150 lines (128 loc) · 4.24 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch: # 允许手动触发,方便测试
jobs:
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
platform: mac
- os: windows-latest
platform: win
- os: ubuntu-latest
platform: linux
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
# Setup Python 3.11 for node-gyp (Python 3.12+ removed distutils)
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Windows 需要配置 node-gyp 使用正确的 Python 和 MSVS 版本(通过环境变量)
- name: Configure node-gyp for Windows
if: matrix.platform == 'win'
shell: bash
run: |
echo "npm_config_python=python" >> $GITHUB_ENV
echo "npm_config_msvs_version=2022" >> $GITHUB_ENV
# 确保 Windows 有 Visual Studio Build Tools
- name: Setup MSBuild (Windows)
if: matrix.platform == 'win'
uses: microsoft/setup-msbuild@v2
# Linux 需要额外的系统依赖来构建 Electron 应用
- name: Install Linux dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 libdrm2 libgbm1 libxcb-dri3-0
- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Cache node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install dependencies
run: bun install
env:
# 跳过 Vercel 环境检查,确保 postinstall 脚本运行
VERCEL: ''
# 确保 node-gyp 找到正确的 Python 版本(Windows 用 python,macOS/Linux 用 python3)
PYTHON: ${{ matrix.platform == 'win' && 'python' || 'python3' }}
- name: Download Claude binaries
run: bun run claude:download:all
- name: Build application
run: bun run build
- name: Package application
run: bun run package:${{ matrix.platform }}
env:
# 跳过 macOS 代码签名
CSC_IDENTITY_AUTO_DISCOVERY: false
# Upload only distributable installers (not build directories or temp files)
# macOS: *.dmg, *.zip, latest-mac*.yml
# Windows: *.exe (NSIS), *.exe (portable), latest*.yml
# Linux: *.AppImage, *.deb
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-installer
path: |
release/*.dmg
release/*.zip
release/*.exe
release/*.AppImage
release/*.deb
release/*.yml
release/*.yaml
retention-days: 7
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts
- name: Create Release
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
generate_release_notes: true
files: |
artifacts/**/*.dmg
artifacts/**/*.zip
artifacts/**/*.exe
artifacts/**/*.AppImage
artifacts/**/*.deb
artifacts/**/*.yml
artifacts/**/*.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}