-
Notifications
You must be signed in to change notification settings - Fork 19
215 lines (182 loc) · 6.05 KB
/
release.yml
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: cd for ez-cursor-free
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
# Windows 构建
build-windows:
name: Build for Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: latest
- name: Install Dependencies
run: pnpm install
- name: Build Electron App
run: pnpm run build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Windows Package
run: pnpm run build:win
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List Build Output
run: dir dist
shell: cmd
- name: Upload Windows Artifacts
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/*.*
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: false
# Mac 构建
build-macos:
name: Build for macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: latest
- name: Install Dependencies
run: pnpm install
# 添加 Rosetta 2 支持
- name: Install Rosetta 2
run: softwareupdate --install-rosetta --agree-to-license
- name: Build Electron App
run: pnpm run build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 分别构建 Intel 和 ARM 版本
- name: Build macOS Intel Package
run: pnpm run build:mac --x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build macOS ARM Package
run: pnpm run build:mac --arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List Build Output
run: ls -la dist
- name: Upload macOS Artifacts
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/*.*
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: false
# Linux 构建
build-linux:
name: Build for Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
# 更新 Ubuntu 软件源
- name: Ubuntu Update with sudo
run: sudo apt-get update
# 安装依赖
- name: Install RPM & Pacman
run: |
sudo apt-get install --no-install-recommends -y rpm &&
sudo apt-get install --no-install-recommends -y libarchive-tools &&
sudo apt-get install --no-install-recommends -y libopenjp2-tools
# 安装项目依赖
- name: Install Dependencies
run: npm install
# 构建 Electron App
- name: Build Electron App for Linux
run: npm run build:linux || true
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 上传构建产物
- name: Upload Linux Artifacts
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/*.*
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: false
# 创建 Release
create-release:
needs: [build-windows, build-macos, build-linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整的 git 历史记录
- name: Generate Release Notes
id: release_notes
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "Processing version: $VERSION"
# 首先尝试从 CHANGELOG.md 获取
if [ -f CHANGELOG.md ]; then
CHANGES=$(awk -v ver="$VERSION" '
BEGIN { found=0; content="" }
/^## \[?'$VERSION'\]?/ { found=1; next }
/^## \[?[0-9]+\.[0-9]+\.[0-9]+/ { if (found) exit }
{ if (found) content = content $0 "\n" }
END { printf "%s", content }
' CHANGELOG.md)
fi
# 如果 CHANGELOG 中没有找到,则使用 git log
if [ -z "$CHANGES" ]; then
echo "No changelog entry found, using git log..."
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
CHANGES=$(git log --pretty=format:"* %s" $PREV_TAG..HEAD)
else
CHANGES=$(git log --pretty=format:"* %s" -n 10)
fi
fi
# 如果还是空的,使用默认消息
if [ -z "$CHANGES" ]; then
CHANGES="Release version $VERSION"
fi
# 添加版本标题
FINAL_NOTES="## Release v$VERSION\n\n$CHANGES"
# 输出到 GITHUB_OUTPUT
{
echo "CHANGES<<EOF"
echo -e "$FINAL_NOTES"
echo "EOF"
} >> $GITHUB_OUTPUT
# 调试输出
echo "Generated release notes:"
echo -e "$FINAL_NOTES"
shell: bash
- name: Update Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: Release ${{ github.ref_name }}
body: ${{ steps.release_notes.outputs.CHANGES }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: false # 不使用 GitHub 自动生成的发布说明