windows-test.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. name: Windows Test Package
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - "ci/windows-test-*"
  7. permissions:
  8. contents: read
  9. jobs:
  10. build-windows:
  11. name: Build Windows x64 test package
  12. runs-on: windows-latest
  13. env:
  14. CARGO_PROFILE_RELEASE_LTO: "false"
  15. CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
  16. CARGO_PROFILE_RELEASE_OPT_LEVEL: "1"
  17. steps:
  18. - name: Checkout
  19. uses: actions/checkout@v5
  20. - name: Install Rust stable
  21. uses: dtolnay/rust-toolchain@stable
  22. - name: Rust cache
  23. uses: Swatinem/rust-cache@v2
  24. with:
  25. workspaces: src-tauri
  26. - name: Install protoc (Windows)
  27. uses: arduino/setup-protoc@v3
  28. with:
  29. repo-token: ${{ secrets.GITHUB_TOKEN }}
  30. - name: Setup Node.js
  31. uses: actions/setup-node@v5
  32. with:
  33. node-version: 24
  34. cache: npm
  35. - name: Install frontend dependencies
  36. run: npm ci
  37. - name: Build Tauri NSIS installer
  38. env:
  39. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  40. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
  41. run: npx tauri build --bundles nsis
  42. - name: Build Windows portable
  43. shell: pwsh
  44. run: |
  45. $ErrorActionPreference = "Stop"
  46. $version = node -p "require('./package.json').version"
  47. $sha = "${{ github.sha }}".Substring(0, 7)
  48. node scripts/build-portable.mjs
  49. $portableExe = "release-portable/QMaiWrite.exe"
  50. if (-not (Test-Path $portableExe)) {
  51. throw "便携版 EXE 未生成:$portableExe"
  52. }
  53. $assetDir = "windows-test-assets"
  54. New-Item -ItemType Directory -Force -Path $assetDir | Out-Null
  55. Copy-Item $portableExe (Join-Path $assetDir "QMaiWrite_${version}_windows_X64_portable_${sha}.exe") -Force
  56. $bundleDir = "src-tauri/target/release/bundle/nsis"
  57. $installer = Get-ChildItem $bundleDir -File -Filter "*.exe" |
  58. Sort-Object LastWriteTime -Descending |
  59. Select-Object -First 1
  60. if (-not $installer) {
  61. throw "未找到 Windows 安装包"
  62. }
  63. Copy-Item $installer.FullName (Join-Path $assetDir "QMaiWrite_${version}_windows_X64_${sha}$($installer.Extension)") -Force
  64. Get-ChildItem $assetDir | Format-Table Name, Length -AutoSize
  65. - name: Upload Windows test package
  66. uses: actions/upload-artifact@v6
  67. with:
  68. name: qmai-windows-x64-test
  69. path: windows-test-assets/*
  70. if-no-files-found: error
  71. retention-days: 14