1- name : Build Release
1+ name : Build & Release
22
33on :
44 workflow_dispatch :
5- release :
6- types : [published]
5+ inputs :
6+ release_type :
7+ description : " Release type"
8+ required : true
9+ default : " patch"
10+ type : choice
11+ options :
12+ - patch
13+ - minor
14+ - major
715
816permissions :
917 contents : write
1018
1119jobs :
12- build :
20+ prepare-release :
21+ runs-on : ubuntu-latest
22+ if : github.event_name == 'workflow_dispatch'
23+ outputs :
24+ new_tag : ${{ steps.get_tag.outputs.tag }}
25+ changelog : ${{ steps.extract_changelog.outputs.notes }}
26+ steps :
27+ - name : Checkout code
28+ uses : actions/checkout@v4
29+ with :
30+ fetch-depth : 0
31+ token : ${{ secrets.GITHUB_TOKEN }}
32+
33+ - name : Setup pnpm
34+ uses : pnpm/action-setup@v4
35+ with :
36+ version : " 10"
37+ run_install : false
38+
39+ - name : Setup Node.js
40+ uses : actions/setup-node@v4
41+ with :
42+ node-version : " 20"
43+ cache : " pnpm"
44+ cache-dependency-path : " pnpm-lock.yaml"
45+
46+ - name : Install dependencies
47+ run : pnpm install --frozen-lockfile
48+
49+ - name : Configure Git
50+ run : |
51+ git config --global user.name "github-actions[bot]"
52+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
53+
54+ - name : Bump version (no commit/tag)
55+ run : pnpm dlx standard-version --release-as ${{ inputs.release_type }} --skip.tag --skip.commit
56+
57+ - name : Sync Tauri version
58+ run : |
59+ 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');"
60+
61+ - name : Commit and tag
62+ run : |
63+ VERSION=$(node -p "require('./package.json').version")
64+ git add package.json pnpm-lock.yaml CHANGELOG.md src-tauri/tauri.conf.json
65+ git commit -m "chore(release): v${VERSION}"
66+ git tag "v${VERSION}"
67+ git push --follow-tags origin HEAD:main
68+
69+ - name : Get new tag
70+ id : get_tag
71+ run : |
72+ TAG=$(git describe --tags --abbrev=0)
73+ echo "tag=$TAG" >> $GITHUB_OUTPUT
74+ echo "Generated new tag: $TAG"
75+
76+ - name : Extract Changelog
77+ id : extract_changelog
78+ run : |
79+ CHANGELOG_CONTENT=$(node .github/scripts/extract-changelog.js)
80+ echo "notes<<EOF" >> $GITHUB_OUTPUT
81+ echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
82+ echo "EOF" >> $GITHUB_OUTPUT
83+
84+ build-mac :
85+ needs : [prepare-release]
1386 strategy :
14- fail-fast : false
1587 matrix :
16- os : [macos-latest, windows-latest]
88+ include :
89+ - os : macos-13
90+ arch : x64
91+ - os : macos-14
92+ arch : arm64
1793 runs-on : ${{ matrix.os }}
18-
1994 steps :
20- - name : Checkout
95+ - name : Checkout code
2196 uses : actions/checkout@v4
97+ with :
98+ ref : ${{ needs.prepare-release.outputs.new_tag }}
2299
23100 - name : Setup pnpm
24101 uses : pnpm/action-setup@v4
25102 with :
26- version : " 9 "
103+ version : " 10 "
27104 run_install : false
28105
29- - name : Setup Node
106+ - name : Setup Node.js
30107 uses : actions/setup-node@v4
31108 with :
32109 node-version : " 20"
@@ -36,30 +113,111 @@ jobs:
36113 - name : Setup Rust
37114 uses : dtolnay/rust-toolchain@stable
38115
39- - name : Install Dependencies
40- run : pnpm install
116+ - name : Install dependencies
117+ run : pnpm install --frozen-lockfile
41118
42- - name : Build App
119+ - name : Build macOS app
43120 run : pnpm tauri build
44121
45- - name : Upload Artifacts
122+ - name : Upload macOS artifacts
46123 uses : actions/upload-artifact@v4
47124 with :
48- name : bundle- ${{ matrix.os }}
125+ name : mac-artifacts- ${{ matrix.arch }}
49126 path : |
50127 src-tauri/target/release/bundle/dmg/*.dmg
128+ src-tauri/target/release/bundle/macos/*.app
129+ if-no-files-found : error
130+
131+ build-win :
132+ needs : [prepare-release]
133+ runs-on : windows-latest
134+ steps :
135+ - name : Checkout code
136+ uses : actions/checkout@v4
137+ with :
138+ ref : ${{ needs.prepare-release.outputs.new_tag }}
139+
140+ - name : Setup pnpm
141+ uses : pnpm/action-setup@v4
142+ with :
143+ version : " 10"
144+ run_install : false
145+
146+ - name : Setup Node.js
147+ uses : actions/setup-node@v4
148+ with :
149+ node-version : " 20"
150+ cache : " pnpm"
151+ cache-dependency-path : " pnpm-lock.yaml"
152+
153+ - name : Setup Rust
154+ uses : dtolnay/rust-toolchain@stable
155+
156+ - name : Install dependencies
157+ run : pnpm install --frozen-lockfile
158+
159+ - name : Build Windows app
160+ run : pnpm tauri build
161+
162+ - name : Upload Windows artifacts
163+ uses : actions/upload-artifact@v4
164+ with :
165+ name : win-artifacts
166+ path : |
51167 src-tauri/target/release/bundle/msi/*.msi
168+ src-tauri/target/release/bundle/nsis/*.exe
169+ if-no-files-found : error
52170
53- - name : Upload Release Assets (macOS)
54- if : github.event_name == 'release' && matrix.os == 'macos-latest'
55- uses : softprops/action-gh-release@v2
171+ release :
172+ needs : [prepare-release, build-mac, build-win]
173+ runs-on : ubuntu-latest
174+ steps :
175+ - name : Download macOS artifacts
176+ uses : actions/download-artifact@v4
56177 with :
57- files : |
58- src-tauri/target/release/bundle/dmg/*.dmg
178+ pattern : mac-artifacts-*
179+ merge-multiple : true
180+ path : artifacts
181+
182+ - name : Download Windows artifacts
183+ uses : actions/download-artifact@v4
184+ with :
185+ name : win-artifacts
186+ path : artifacts
59187
60- - name : Upload Release Assets (Windows)
61- if : github.event_name == 'release' && matrix.os == 'windows-latest'
188+ - name : Create GitHub Release
62189 uses : softprops/action-gh-release@v2
63190 with :
191+ tag_name : ${{ needs.prepare-release.outputs.new_tag }}
192+ draft : false
193+ prerelease : false
64194 files : |
65- src-tauri/target/release/bundle/msi/*.msi
195+ artifacts/**/skills-manager-gui*.dmg
196+ artifacts/**/skills-manager-gui*.msi
197+ artifacts/**/skills-manager-gui*.exe
198+ body : |
199+ ## 🎉 新版本发布!
200+
201+ **注意:本项目暂无商业签名证书,安装时可能会提示安全警告。**
202+
203+ ### 🍎 macOS 用户
204+ 初次安装可能出现 “应用已损坏,无法打开” 或 “来自身份不明的开发者”。
205+
206+ 请打开「终端」执行:
207+
208+ ```bash
209+ xattr -cr /Applications/skills-manager-gui.app
210+ ```
211+
212+ ### 🪟 Windows 用户
213+ 如果出现 SmartScreen 提示:
214+
215+ 1. 点击 “更多信息”
216+ 2. 点击 “仍要运行”
217+
218+ ---
219+
220+ ### 更新日志
221+ ${{ needs.prepare-release.outputs.changelog }}
222+ env :
223+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments