-
Notifications
You must be signed in to change notification settings - Fork 2
222 lines (187 loc) · 7.4 KB
/
release.yml
File metadata and controls
222 lines (187 loc) · 7.4 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v0.1.0)'
required: true
default: 'v'
type: string
permissions:
contents: write
env:
AUTHOR: CmzYa
REPO: sound_link
REPO_URL: https://github.com/CmzYa/sound_link
jobs:
prepare-version:
name: 准备版本号并同步文件
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.version.outputs.tag }}
version: ${{ steps.version.outputs.version }}
changelog: ${{ steps.changelog.outputs.content }}
commit_sha: ${{ steps.commit.outputs.sha }}
steps:
- name: 检出代码
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: 读取当前版本号
id: current
run: |
set -euo pipefail
CURRENT_VERSION=$(jq -r '.version' package.json)
echo "version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "当前文件版本: $CURRENT_VERSION"
- name: 确定目标版本
id: version
run: |
set -euo pipefail
INPUT_VERSION="${{ github.event.inputs.version }}"
VERSION="$(echo "$INPUT_VERSION" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
if [ -z "$VERSION" ]; then
echo "❌ 无法从输入提取版本号: $INPUT_VERSION"
exit 1
fi
TAG="v$VERSION"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "目标版本: $VERSION"
- name: 生成更新日志
id: changelog
uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process');
const version = '${{ steps.version.outputs.version }}';
let commits = '';
try {
const lastTag = execSync('git describe --tags --abbrev=0 2>/dev/null || echo ""', { encoding: 'utf8' }).trim();
let cmd;
if (lastTag) {
console.log('上次发布:', lastTag);
cmd = `git log ${lastTag}..HEAD --pretty=format:"- %s (%h)" --no-merges`;
} else {
console.log('首次发布,获取最近20条提交');
cmd = 'git log -20 --pretty=format:"- %s (%h)" --no-merges';
}
commits = execSync(cmd, { encoding: 'utf8' }).trim();
} catch (e) {
commits = '';
}
let changelogContent = '';
if (!commits || commits.trim() === '') {
changelogContent = '- 版本更新';
} else {
const lines = commits.split('\n');
const processedLines = lines.map(line => {
return line.replace(/^- (feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\([^)]+\))?:\s*/i, '- ')
.replace(/^- ([a-z]+):\s*/i, '- ');
});
changelogContent = processedLines.join('\n');
}
core.setOutput('content', changelogContent);
- name: 同步版本号到文件
run: |
set -euo pipefail
VERSION="${{ steps.version.outputs.version }}"
CURRENT="${{ steps.current.outputs.version }}"
if [ "$VERSION" != "$CURRENT" ]; then
echo "更新版本号: $CURRENT -> $VERSION"
jq --arg v "$VERSION" '.version = $v' package.json > package.json.tmp
mv package.json.tmp package.json
jq --arg v "$VERSION" '.version = $v' src-tauri/tauri.conf.json > tauri.conf.json.tmp
mv tauri.conf.json.tmp src-tauri/tauri.conf.json
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml
cd src-tauri && cargo generate-lockfile
echo "版本号已同步到所有文件"
else
echo "版本号未变化,跳过同步"
fi
- name: 提交版本更新
id: commit
run: |
set -euo pipefail
VERSION="${{ steps.version.outputs.version }}"
CURRENT="${{ steps.current.outputs.version }}"
if [ "$VERSION" != "$CURRENT" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml src-tauri/Cargo.lock
git commit -m "chore: bump version to $VERSION"
git push
echo "版本更新已提交"
fi
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
build-windows:
name: 构建 Windows 版本
needs: prepare-version
strategy:
fail-fast: false
matrix:
include:
- platform: 'windows-latest'
args: ''
arch: 'amd64'
- platform: 'windows-11-arm'
args: ''
arch: 'arm64'
runs-on: ${{ matrix.platform }}
steps:
- name: 检出代码
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-version.outputs.commit_sha }}
fetch-depth: 0
- name: 安装 Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: 安装 Rust 工具链
uses: dtolnay/rust-toolchain@stable
- name: 缓存 Rust 编译产物
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> output/target"
- name: 安装前端依赖
run: npm install
- name: 构建并发布
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ needs.prepare-version.outputs.tag }}
releaseName: "Sound Link v${{ needs.prepare-version.outputs.version }}"
releaseBody: |
## Sound Link v${{ needs.prepare-version.outputs.version }}
> 可视化音频设备切换工具
### 📝 更新内容
${{ needs.prepare-version.outputs.changelog }}
---
### 🎧 功能特点
- 可视化显示系统音频设备
- 一键切换音频输出设备
- 音频路由功能:将系统音频广播到多个设备
- 跟随系统主题(深色/浅色模式)
- 跟随系统主题色
- 高级毛玻璃材质效果
- 系统托盘常驻
### 📥 下载说明
| 平台 | 架构 | 文件格式 |
|------|------|----------|
| Windows | x64 | `.msi` / `.exe` |
| Windows | ARM64 | `.msi` / `.exe` |
### 📦 安装依赖
使用前需安装 [AudioDeviceCmdlets](https://github.com/frgnca/AudioDeviceCmdlets) PowerShell 模块:
```powershell
Install-Module -Name AudioDeviceCmdlets -Force
```
---
**作者**: [@CmzYa](https://github.com/CmzYa)
**仓库**: [https://github.com/CmzYa/sound_link](https://github.com/CmzYa/sound_link)
**许可证**: GPL-3.0 License
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}