@@ -3,25 +3,153 @@ name: Release
33on :
44 push :
55 tags :
6- - " v*"
6+ - " v*.*.* "
77 workflow_dispatch :
88 inputs :
9- version :
10- description : " Version tag to release, e.g. v0.1 .0"
9+ tag :
10+ description : " Release tag,例如 v0.2 .0"
1111 required : true
12- default : " v0.1 .0"
12+ default : " v0.2 .0"
1313 source_ref :
14- description : " Git ref to build from, e.g. main or v0.1.0"
15- required : false
16- default : " "
14+ description : " 构建来源,例如 main"
15+ required : true
16+ default : " main"
17+ platform :
18+ description : " 发布平台"
19+ required : true
20+ default : " all"
21+ type : choice
22+ options :
23+ - all
24+ - windows
25+ - mac
26+ - linux
1727
1828permissions :
1929 contents : write
2030
2131jobs :
22- build_release_preview :
23- name : Build Release Preview
32+ build_windows :
33+ name : Build Windows
34+ if : github.event_name == 'push' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'windows'
35+ runs-on : windows-latest
36+ timeout-minutes : 45
37+
38+ steps :
39+ - name : Checkout
40+ uses : actions/checkout@v4
41+ with :
42+ fetch-depth : 0
43+ ref : ${{ github.event.inputs.source_ref || github.ref }}
44+
45+ - name : Resolve release metadata
46+ id : meta
47+ shell : bash
48+ run : |
49+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
50+ TAG="${{ github.event.inputs.tag }}"
51+ SOURCE_REF="${{ github.event.inputs.source_ref }}"
52+ else
53+ TAG="${GITHUB_REF#refs/tags/}"
54+ SOURCE_REF="${GITHUB_REF}"
55+ fi
56+
57+ VERSION="${TAG#v}"
58+ echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
59+ echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
60+ echo "source_ref=${SOURCE_REF}" >> "$GITHUB_OUTPUT"
61+
62+ - name : Setup Node.js
63+ uses : actions/setup-node@v4
64+ with :
65+ node-version : " 22"
66+ cache : " npm"
67+ cache-dependency-path : " package-lock.json"
68+
69+ - name : Install dependencies
70+ run : npm ci
71+
72+ - name : Sync package versions
73+ run : node scripts/sync-version.mjs ${{ steps.meta.outputs.version }}
74+
75+ - name : Build Windows artifacts
76+ run : npm run dist:win
77+ env :
78+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79+
80+ - name : Upload Windows artifacts
81+ uses : actions/upload-artifact@v4
82+ with :
83+ name : lime-novel-windows
84+ path : |
85+ dist/*
86+ !dist/builder-debug.yml
87+ !dist/win-unpacked
88+
89+ build_macos :
90+ name : Build macOS
91+ if : github.event_name == 'push' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'mac'
92+ runs-on : macos-latest
93+ timeout-minutes : 45
94+
95+ steps :
96+ - name : Checkout
97+ uses : actions/checkout@v4
98+ with :
99+ fetch-depth : 0
100+ ref : ${{ github.event.inputs.source_ref || github.ref }}
101+
102+ - name : Resolve release metadata
103+ id : meta
104+ shell : bash
105+ run : |
106+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
107+ TAG="${{ github.event.inputs.tag }}"
108+ SOURCE_REF="${{ github.event.inputs.source_ref }}"
109+ else
110+ TAG="${GITHUB_REF#refs/tags/}"
111+ SOURCE_REF="${GITHUB_REF}"
112+ fi
113+
114+ VERSION="${TAG#v}"
115+ echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
116+ echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
117+ echo "source_ref=${SOURCE_REF}" >> "$GITHUB_OUTPUT"
118+
119+ - name : Setup Node.js
120+ uses : actions/setup-node@v4
121+ with :
122+ node-version : " 22"
123+ cache : " npm"
124+ cache-dependency-path : " package-lock.json"
125+
126+ - name : Install dependencies
127+ run : npm ci
128+
129+ - name : Sync package versions
130+ run : node scripts/sync-version.mjs ${{ steps.meta.outputs.version }}
131+
132+ - name : Build macOS artifacts
133+ run : npm run dist:mac
134+ env :
135+ CSC_IDENTITY_AUTO_DISCOVERY : " false"
136+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
137+
138+ - name : Upload macOS artifacts
139+ uses : actions/upload-artifact@v4
140+ with :
141+ name : lime-novel-macos
142+ path : |
143+ dist/*
144+ !dist/builder-debug.yml
145+ !dist/mac
146+ !dist/mac-arm64
147+
148+ build_linux :
149+ name : Build Linux
150+ if : github.event_name == 'push' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux'
24151 runs-on : ubuntu-latest
152+ timeout-minutes : 45
25153
26154 steps :
27155 - name : Checkout
@@ -30,36 +158,113 @@ jobs:
30158 fetch-depth : 0
31159 ref : ${{ github.event.inputs.source_ref || github.ref }}
32160
161+ - name : Resolve release metadata
162+ id : meta
163+ shell : bash
164+ run : |
165+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
166+ TAG="${{ github.event.inputs.tag }}"
167+ SOURCE_REF="${{ github.event.inputs.source_ref }}"
168+ else
169+ TAG="${GITHUB_REF#refs/tags/}"
170+ SOURCE_REF="${GITHUB_REF}"
171+ fi
172+
173+ VERSION="${TAG#v}"
174+ echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
175+ echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
176+ echo "source_ref=${SOURCE_REF}" >> "$GITHUB_OUTPUT"
177+
33178 - name : Setup Node.js
34179 uses : actions/setup-node@v4
35180 with :
36181 node-version : " 22"
37182 cache : " npm"
38183 cache-dependency-path : " package-lock.json"
39184
185+ - name : Install Linux packaging dependencies
186+ run : |
187+ sudo apt-get update
188+ sudo apt-get install -y libarchive-tools rpm
189+
40190 - name : Install dependencies
41191 run : npm ci
42192
43- - name : Build preview output
44- run : npm run build
193+ - name : Sync package versions
194+ run : node scripts/sync-version.mjs ${{ steps.meta.outputs.version }}
195+
196+ - name : Build Linux artifacts
197+ run : npm run dist:linux
198+ env :
199+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
200+
201+ - name : Upload Linux artifacts
202+ uses : actions/upload-artifact@v4
203+ with :
204+ name : lime-novel-linux
205+ path : |
206+ dist/*
207+ !dist/builder-debug.yml
208+ !dist/linux-unpacked
209+
210+ publish_release :
211+ name : Publish Draft Release
212+ runs-on : ubuntu-latest
213+ needs :
214+ - build_windows
215+ - build_macos
216+ - build_linux
217+ if : |
218+ always() &&
219+ !contains(needs.*.result, 'failure') &&
220+ !contains(needs.*.result, 'cancelled')
45221
46- - name : Package preview build
222+ steps :
223+ - name : Resolve release metadata
224+ id : meta
47225 shell : bash
48226 run : |
49- TAG="${{ github.event.inputs.version || github.ref_name }}"
50- mkdir -p release
51- tar -czf "release/lime-novel-${TAG}-preview-build.tar.gz" out package.json package-lock.json
227+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
228+ TAG="${{ github.event.inputs.tag }}"
229+ SOURCE_REF="${{ github.event.inputs.source_ref }}"
230+ else
231+ TAG="${GITHUB_REF#refs/tags/}"
232+ SOURCE_REF="${GITHUB_REF}"
233+ fi
234+
235+ VERSION="${TAG#v}"
236+ echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
237+ echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
238+ echo "source_ref=${SOURCE_REF}" >> "$GITHUB_OUTPUT"
239+
240+ - name : Download Windows artifacts
241+ if : needs.build_windows.result == 'success'
242+ uses : actions/download-artifact@v4
243+ with :
244+ name : lime-novel-windows
245+ path : release-assets
246+
247+ - name : Download macOS artifacts
248+ if : needs.build_macos.result == 'success'
249+ uses : actions/download-artifact@v4
250+ with :
251+ name : lime-novel-macos
252+ path : release-assets
253+
254+ - name : Download Linux artifacts
255+ if : needs.build_linux.result == 'success'
256+ uses : actions/download-artifact@v4
257+ with :
258+ name : lime-novel-linux
259+ path : release-assets
52260
53261 - name : Publish GitHub release
54262 uses : softprops/action-gh-release@v2
55263 with :
56- tag_name : ${{ github.event.inputs.version || github.ref_name }}
57- name : Lime Novel ${{ github.event.inputs.version || github.ref_name }}
58- prerelease : ${{ contains(github.event.inputs.version || github.ref_name, '-') }}
264+ tag_name : ${{ steps.meta.outputs.tag }}
265+ target_commitish : ${{ steps.meta.outputs.source_ref }}
266+ name : Lime Novel ${{ steps.meta.outputs.tag }}
267+ draft : true
268+ prerelease : ${{ contains(steps.meta.outputs.tag, '-') }}
59269 generate_release_notes : true
60- body : |
61- 这是当前 `lime-novel` 的预览构建产物。
62-
63- 当前仓库尚未接入桌面安装包打包与签名链路,因此本次 release 先附带 `preview build`,用于内部验证与版本归档。
64- files : |
65- release/*.tar.gz
270+ files : release-assets/*
0 commit comments