Repository navigation
194 lines (172 loc) · 7.32 KB
/
Copy pathreusable-client-build.yml
File metadata and controls
194 lines (172 loc) · 7.32 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
# =============================================================================
# Reusable Workflow: Client 全平台构建
#
# Tauri 桌面客户端多平台构建,支持两种模式:
# - preview: PR 预览,产物上传为 artifact(保留 5 天)
# - release: 正式发布,产物上传到 GitHub Release
# 平台: macOS (arm64/x64), Windows (x64), Linux (x64)
# 产物: DMG, App, MSI, EXE, AppImage, Deb
# =============================================================================
name: 'Reusable: Client Build'
on:
workflow_call:
inputs:
mode:
description: 'preview: upload artifacts | release: upload to GitHub Release'
required: false
type: string
default: 'preview'
client_version:
description: 'Client version for GitHub Release tag (required for release mode)'
required: false
type: string
default: ''
jobs:
client-build:
runs-on: ${{ matrix.platform }}
continue-on-error: ${{ inputs.mode == 'preview' }}
timeout-minutes: 60
strategy:
fail-fast: false
max-parallel: 4
matrix:
include:
- platform: macos-latest
target: aarch64-apple-darwin
platform_name: macos
arch: arm64
args: '--target aarch64-apple-darwin'
- platform: macos-latest
target: x86_64-apple-darwin
platform_name: macos
arch: x64
args: '--target x86_64-apple-darwin'
- platform: windows-latest
target: x86_64-pc-windows-msvc
platform_name: windows
arch: x64
args: '--target x86_64-pc-windows-msvc'
- platform: ubuntu-latest
target: x86_64-unknown-linux-gnu
platform_name: linux
arch: x64
args: '--target x86_64-unknown-linux-gnu'
steps:
- uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'yarn'
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
# Preview 模式: 使用独立的 rust-cache(只读,不保存新缓存)
- name: Cache Rust Dependencies (Preview)
if: inputs.mode == 'preview'
uses: Swatinem/rust-cache@v2
with:
workspaces: packages/client/src-tauri -> target
save-if: false
- name: Install Linux Dependencies
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install Dependencies
run: yarn --network-timeout 100000
- name: Build Cherry Markdown
run: yarn build
- name: Build Tauri Client
run: yarn build:client ${{ matrix.args }}
# =========================================================================
# Preview 模式: 上传 artifact(保留 5 天)
# =========================================================================
# macOS: Upload DMG
- name: Upload DMG
if: inputs.mode == 'preview' && matrix.platform_name == 'macos'
uses: actions/upload-artifact@v4
with:
name: client-${{ matrix.platform_name }}-${{ matrix.arch }}-dmg
path: ./packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/dmg/*.dmg
retention-days: 5
if-no-files-found: warn
# macOS: Upload App
- name: Upload App
if: inputs.mode == 'preview' && matrix.platform_name == 'macos'
uses: actions/upload-artifact@v4
with:
name: client-${{ matrix.platform_name }}-${{ matrix.arch }}-app
path: ./packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/macos/*.app
retention-days: 5
if-no-files-found: warn
# Windows: Upload MSI
- name: Upload MSI
if: inputs.mode == 'preview' && matrix.platform_name == 'windows'
uses: actions/upload-artifact@v4
with:
name: client-${{ matrix.platform_name }}-${{ matrix.arch }}-msi
path: ./packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/msi/*.msi
retention-days: 5
if-no-files-found: warn
# Windows: Upload NSIS Exe
- name: Upload NSIS Installer
if: inputs.mode == 'preview' && matrix.platform_name == 'windows'
uses: actions/upload-artifact@v4
with:
name: client-${{ matrix.platform_name }}-${{ matrix.arch }}-exe
path: ./packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*.exe
retention-days: 5
if-no-files-found: warn
# Linux: Upload AppImage
- name: Upload AppImage
if: inputs.mode == 'preview' && matrix.platform_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: client-${{ matrix.platform_name }}-${{ matrix.arch }}-appimage
path: ./packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage
retention-days: 5
if-no-files-found: warn
# Linux: Upload Deb
- name: Upload Deb
if: inputs.mode == 'preview' && matrix.platform_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: client-${{ matrix.platform_name }}-${{ matrix.arch }}-deb
path: ./packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
retention-days: 5
if-no-files-found: warn
# =========================================================================
# Release 模式: 上传到 GitHub Release
# =========================================================================
# macOS: Upload Release Assets
- name: Upload macOS Release Asset
if: inputs.mode == 'release' && matrix.platform_name == 'macos'
uses: AButler/upload-release-assets@v3.0
with:
files: |
packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/dmg/*.dmg
release-tag: '@cherry-markdown/client@${{ inputs.client_version }}'
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Windows: Upload Release Assets
- name: Upload Windows Release Asset
if: inputs.mode == 'release' && matrix.platform_name == 'windows'
uses: AButler/upload-release-assets@v3.0
with:
files: |
packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/msi/*.msi;
packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*.exe
release-tag: '@cherry-markdown/client@${{ inputs.client_version }}'
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Linux: Upload Release Assets
- name: Upload Linux Release Asset
if: inputs.mode == 'release' && matrix.platform_name == 'linux'
uses: AButler/upload-release-assets@v3.0
with:
files: |
packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb;
packages/client/src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage
release-tag: '@cherry-markdown/client@${{ inputs.client_version }}'
repo-token: ${{ secrets.GITHUB_TOKEN }}