-
Notifications
You must be signed in to change notification settings - Fork 14
197 lines (166 loc) · 5.2 KB
/
release.yml
File metadata and controls
197 lines (166 loc) · 5.2 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
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
name: Build & Release
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
# 1. 准备发布:生成版本号、Changelog、打 Tag
prepare-release:
runs-on: ubuntu-latest
# 只有手动触发时才运行此步骤
if: github.event_name == 'workflow_dispatch'
outputs:
new_tag: ${{ steps.get_tag.outputs.tag }}
changelog: ${{ steps.extract_changelog.outputs.notes }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and push
run: |
npm ci
# 运行 standard-version 更新版本和 Changelog
npx standard-version --release-as ${{ inputs.release_type }}
# 推送 commits 和 tags 到 main
git push --follow-tags origin HEAD:main
- name: Get new tag
id: get_tag
run: |
# 获取最新的 tag
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Generated new tag: $TAG"
- name: Extract Changelog
id: extract_changelog
run: |
# 提取最新版本的 Changelog 内容
CHANGELOG_CONTENT=$(node .github/scripts/extract-changelog.js)
# 处理多行文本输出到 GITHUB_OUTPUT
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# 2. 构建 macOS
build-mac:
needs: [prepare-release]
strategy:
matrix:
include:
- os: macos-15-intel
arch: x64
args: --x64
- os: macos-latest
arch: arm64
args: --arm64
runs-on: ${{ matrix.os }}
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-release.outputs.new_tag }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build macOS app (unsigned)
run: |
npm run build -- \
--mac ${{ matrix.args }} \
-c.mac.identity=null \
-c.mac.hardenedRuntime=false \
--publish never
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: mac-artifacts-${{ matrix.arch }}
path: release/**/*.dmg
if-no-files-found: error
# 3. 构建 Windows
build-win:
needs: [prepare-release]
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-release.outputs.new_tag }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build Windows app (unsigned)
run: npm run build -- --win --publish never
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: win-artifacts
path: release/**/*.exe
if-no-files-found: error
# 4. 发布 Release
release:
needs: [prepare-release, build-mac, build-win]
runs-on: ubuntu-latest
steps:
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
pattern: mac-artifacts-*
merge-multiple: true
path: artifacts
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: win-artifacts
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare-release.outputs.new_tag }}
draft: true
prerelease: false
files: artifacts/**
body: |
## 🎉 新版本发布!
**注意:本项目暂无商业签名证书,安装时可能会提示安全警告。**
### 🍎 macOS 用户
初次安装可能出现 “应用已损坏,无法打开” 或 “来自身份不明的开发者”。
请打开「终端」执行:
```bash
xattr -cr /Applications/Voice\ Key.app
```
### 🪟 Windows 用户
如果出现 SmartScreen 提示:
1. 点击 “更多信息”
2. 点击 “仍要运行”
---
### 更新日志
${{ needs.prepare-release.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}