feat: Windows dual build - lightweight + full WebView2 installer

This commit is contained in:
晴天
2026-04-02 17:05:37 +08:00
parent 10efe1cc0a
commit 3b85bc6f01
8 changed files with 82 additions and 20 deletions

View File

@@ -41,6 +41,10 @@ jobs:
os: windows-latest
args: ""
rust_target: ""
- name: Windows (x64) 完整包
os: windows-latest
args: ""
rust_target: ""
steps:
- name: 签出代码
@@ -91,6 +95,7 @@ jobs:
libayatana-appindicator3-dev
- name: 构建 Tauri 应用
if: matrix.platform.name != 'Windows (x64) 完整包'
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -112,6 +117,49 @@ jobs:
prerelease: false
args: ${{ matrix.platform.args }}
# ── Windows 完整包(内嵌 WebView2 离线安装器)──────────────────────────────
- name: 配置 WebView2 完整包模式
if: matrix.platform.name == 'Windows (x64) 完整包'
shell: bash
run: |
node -e "
const fs = require('fs');
const f = 'src-tauri/tauri.conf.json';
const c = JSON.parse(fs.readFileSync(f, 'utf8'));
c.bundle.windows.webviewInstallMode = { type: 'offlineInstaller', silent: true };
fs.writeFileSync(f, JSON.stringify(c, null, 2));
"
- name: 构建 Windows 完整包
if: matrix.platform.name == 'Windows (x64) 完整包'
shell: bash
run: npx tauri build
- name: 重命名并上传完整包
if: matrix.platform.name == 'Windows (x64) 完整包'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${TAG_NAME#v}"
BUNDLE_DIR="src-tauri/target/release/bundle"
# 确保 Release 已存在(可能被其他 matrix job 的 tauri-action 创建)
gh release create "$TAG_NAME" --title "ClawPanel $TAG_NAME" \
--notes "正在构建所有平台安装包,请稍候..." 2>/dev/null || true
# 重命名 NSIS exe 并上传
mv "${BUNDLE_DIR}/nsis/ClawPanel_${VERSION}_x64-setup.exe" \
"${BUNDLE_DIR}/nsis/ClawPanel_${VERSION}_x64-setup-full.exe"
gh release upload "$TAG_NAME" \
"${BUNDLE_DIR}/nsis/ClawPanel_${VERSION}_x64-setup-full.exe" --clobber
# 重命名 MSI 并上传
mv "${BUNDLE_DIR}/msi/ClawPanel_${VERSION}_x64_en-US.msi" \
"${BUNDLE_DIR}/msi/ClawPanel_${VERSION}_x64-full_en-US.msi"
gh release upload "$TAG_NAME" \
"${BUNDLE_DIR}/msi/ClawPanel_${VERSION}_x64-full_en-US.msi" --clobber
# ── 所有平台构建完成后,统一更新 Release Notes ─────────────────────────────
# 独立 job 确保只执行一次,彻底避免多个 matrix job 的竞争条件
update-release-notes:
@@ -270,10 +318,14 @@ jobs:
echo '> **⚠️ 首次打开提示"无法验证开发者"** 在终端执行:`sudo xattr -rd com.apple.quarantine /Applications/ClawPanel.app`,或前往 **系统设置 → 隐私与安全性** 点击「仍要打开」。'
echo ""
echo "### Windows"
echo "| 格式 | 安装包 |"
echo "|------|--------|"
echo "| EXE 安装器(推荐) | [ClawPanel_${VERSION}_x64-setup.exe](${DL}/ClawPanel_${VERSION}_x64-setup.exe) |"
echo "| MSI 安装器 | [ClawPanel_${VERSION}_x64_en-US.msi](${DL}/ClawPanel_${VERSION}_x64_en-US.msi) |"
echo "| 格式 | 安装包 | 说明 |"
echo "|------|--------|------|"
echo "| EXE 安装器(推荐) | [ClawPanel_${VERSION}_x64-setup.exe](${DL}/ClawPanel_${VERSION}_x64-setup.exe) | 轻量版 ~10 MB |"
echo "| EXE 完整包 | [ClawPanel_${VERSION}_x64-setup-full.exe](${DL}/ClawPanel_${VERSION}_x64-setup-full.exe) | 含 WebView2 ~200 MB |"
echo "| MSI 安装器 | [ClawPanel_${VERSION}_x64_en-US.msi](${DL}/ClawPanel_${VERSION}_x64_en-US.msi) | 轻量版 ~10 MB |"
echo "| MSI 完整包 | [ClawPanel_${VERSION}_x64-full_en-US.msi](${DL}/ClawPanel_${VERSION}_x64-full_en-US.msi) | 含 WebView2 ~200 MB |"
echo ""
echo "> **💡 轻量版 vs 完整包**Win10 1803+ 和 Win11 已预装 WebView2推荐下载轻量版。如果是内网/断网环境,选择完整包。"
echo ""
echo "### Linux"
echo "| 格式 | 安装包 |"