-
Notifications
You must be signed in to change notification settings - Fork 14
240 lines (202 loc) · 7.19 KB
/
Copy pathrelease.yml
File metadata and controls
240 lines (202 loc) · 7.19 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
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:
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 pnpm
uses: pnpm/action-setup@v4
with:
version: "10"
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- 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 (no commit/tag)
run: pnpm dlx standard-version --release-as ${{ inputs.release_type }} --skip.tag --skip.commit
- name: Sync Tauri version
run: |
node -e "const fs=require('fs');const pkg=require('./package.json');const path='src-tauri/tauri.conf.json';const conf=JSON.parse(fs.readFileSync(path,'utf8'));conf.version=pkg.version;fs.writeFileSync(path, JSON.stringify(conf,null,2)+'\\n');"
- name: Commit and tag
run: |
VERSION=$(node -p "require('./package.json').version")
git add package.json pnpm-lock.yaml CHANGELOG.md src-tauri/tauri.conf.json
git commit -m "chore(release): v${VERSION}"
git tag -a "v${VERSION}" -m "v${VERSION}"
git push --follow-tags origin HEAD:main
- name: Get new tag
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Generated new tag: $TAG"
- name: Extract Changelog
id: extract_changelog
run: |
CHANGELOG_CONTENT=$(node .github/scripts/extract-changelog.js)
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
build-mac:
needs: [prepare-release]
strategy:
matrix:
include:
- os: macos-15-intel
arch: x64
- os: macos-latest
arch: arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-release.outputs.new_tag }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: "10"
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build macOS app
run: pnpm tauri build
- name: Rename macOS artifacts
run: |
VERSION=${{ needs.prepare-release.outputs.new_tag }}
VERSION=${VERSION#v}
DMG=$(ls src-tauri/target/release/bundle/dmg/*.dmg | head -n 1)
mv "$DMG" "src-tauri/target/release/bundle/dmg/skills-manager-gui_${VERSION}_macos-${{ matrix.arch }}.dmg"
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: mac-artifacts-${{ matrix.arch }}
path: |
src-tauri/target/release/bundle/dmg/skills-manager-gui_*.dmg
if-no-files-found: error
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 pnpm
uses: pnpm/action-setup@v4
with:
version: "10"
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Windows app
run: pnpm tauri build
- name: Rename Windows artifacts
shell: pwsh
run: |
$version = "${{ needs.prepare-release.outputs.new_tag }}".TrimStart("v")
$msi = Get-ChildItem "src-tauri/target/release/bundle/msi" -Filter "*.msi" | Select-Object -First 1
if ($msi) {
Rename-Item $msi.FullName (Join-Path $msi.DirectoryName "skills-manager-gui_${version}_windows-x64.msi")
}
$exe = Get-ChildItem "src-tauri/target/release/bundle/nsis" -Filter "*.exe" | Select-Object -First 1
if ($exe) {
Rename-Item $exe.FullName (Join-Path $exe.DirectoryName "skills-manager-gui_${version}_windows-x64-setup.exe")
}
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: win-artifacts
path: |
src-tauri/target/release/bundle/msi/skills-manager-gui_*.msi
src-tauri/target/release/bundle/nsis/skills-manager-gui_*.exe
if-no-files-found: error
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: false
prerelease: false
files: |
artifacts/**/skills-manager-gui_*.dmg
artifacts/**/skills-manager-gui_*.msi
artifacts/**/skills-manager-gui_*.exe
body: |
## 🎉 新版本发布!
**注意:本项目暂无商业签名证书,安装时可能会提示安全警告。**
### 🍎 macOS 用户
初次安装可能出现 “应用已损坏,无法打开” 或 “来自身份不明的开发者”。
请打开「终端」执行:
```bash
xattr -cr /Applications/skills-manager-gui.app
```
### 🪟 Windows 用户
1. 点击 “更多信息”
2. 点击 “仍要运行”
---
### 更新日志
${{ needs.prepare-release.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}