1111 # 缓存 Cargo 依赖,加速 Rust 编译
1212 - /root/.cargo/registry:copy-on-write
1313 - /root/.cargo/git:copy-on-write
14+ # 缓存 xwin Windows SDK 下载缓存
15+ - /root/.xwin-cache:copy-on-write
1416 # 缓存 pnpm 依赖
1517 - /root/.local/share/pnpm/store:copy-on-write
1618 stages :
@@ -20,23 +22,19 @@ main:
2022 apt-get update -qq
2123 apt-get install -y --no-install-recommends \
2224 curl wget git jq ca-certificates \
23- build-essential pkg-config libssl-dev \
24- libwebkit2gtk-4.1-dev \
25- libgtk-3-dev \
26- libayatana-appindicator3-dev \
27- librsvg2-dev \
28- patchelf \
29- libxdo-dev \
30- libsoup-3.0-dev \
31- libjavascriptcoregtk-4.1-dev \
32- file
25+ build-essential pkg-config \
26+ clang llvm lld \
27+ libssl-dev
3328
34- - name : 安装 Rust 工具链
29+ - name : 安装 Rust 工具链与 Windows 交叉编译目标
3530 script : |
3631 if ! command -v rustup &>/dev/null; then
3732 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
3833 fi
3934 . "$HOME/.cargo/env"
35+ rustup target add x86_64-pc-windows-msvc
36+ # 安装 cargo-xwin 用于 Windows 交叉编译
37+ cargo install cargo-xwin --locked
4038 rustup show
4139
4240 - name : 安装 Node.js 与 pnpm
@@ -63,10 +61,11 @@ main:
6361 script : |
6462 pnpm install
6563
66- - name : 构建应用
64+ - name : 交叉编译 Windows 应用 (exe + msi + nsis)
6765 script : |
6866 . "$HOME/.cargo/env"
69- pnpm build
67+ # 使用 cargo-xwin 交叉编译到 Windows x86_64
68+ pnpm tauri build --target x86_64-pc-windows-msvc --runner cargo-xwin
7069 timeout : 2h
7170
7271 - name : 创建并推送 Tag
@@ -113,9 +112,9 @@ main:
113112
114113 - name : 上传构建产物到 Release
115114 script : |
116- APPIMAGE_DIR="src-tauri/target/release/bundle/appimage"
117- DEB_DIR ="src-tauri/target/release/bundle/deb "
118- RPM_DIR ="src-tauri/target/release/bundle/rpm "
115+ # Windows 交叉编译产物路径
116+ MSI_DIR ="src-tauri/target/x86_64-pc-windows-msvc/ release/bundle/msi "
117+ NSIS_DIR ="src-tauri/target/x86_64-pc-windows-msvc/ release/bundle/nsis "
119118
120119 upload_file() {
121120 local FILE="$1"
@@ -137,32 +136,24 @@ main:
137136 return 1
138137 fi
139138 echo "正在上传 $ASSET_NAME..."
140- curl --silent -- request PUT --url "$UPLOAD_URL" --upload-file "$FILE"
139+ curl --request PUT --url "$UPLOAD_URL" --upload-file "$FILE"
141140 echo "已上传: $ASSET_NAME"
142141 }
143142
144- if [ -d "$APPIMAGE_DIR " ]; then
145- for file in "$APPIMAGE_DIR "/*; do
143+ if [ -d "$MSI_DIR " ]; then
144+ for file in "$MSI_DIR "/*; do
146145 [ -f "$file" ] && upload_file "$file"
147146 done
148147 else
149- echo "AppImage 目录不存在,跳过"
148+ echo "MSI 目录不存在,跳过"
150149 fi
151150
152- if [ -d "$DEB_DIR " ]; then
153- for file in "$DEB_DIR "/*; do
151+ if [ -d "$NSIS_DIR " ]; then
152+ for file in "$NSIS_DIR "/*; do
154153 [ -f "$file" ] && upload_file "$file"
155154 done
156155 else
157- echo "Deb 目录不存在,跳过"
158- fi
159-
160- if [ -d "$RPM_DIR" ]; then
161- for file in "$RPM_DIR"/*; do
162- [ -f "$file" ] && upload_file "$file"
163- done
164- else
165- echo "RPM 目录不存在,跳过"
156+ echo "NSIS 目录不存在,跳过"
166157 fi
167158
168159 echo "所有构建产物上传完毕"
0 commit comments