ci: cross-build windows internal installer
Some checks failed
Build Windows Internal Installer / Build Windows x64 internal installer (push) Has been cancelled

This commit is contained in:
冰朔 2026-07-16 21:39:16 +08:00
parent d8a0fb9817
commit d10824e685

View File

@ -1,6 +1,11 @@
name: Build Windows Internal Installer name: Build Windows Internal Installer
on: on:
push:
branches:
- main
paths:
- ".github/workflows/build-windows-manual.yml"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: version:
@ -19,7 +24,7 @@ env:
jobs: jobs:
build-windows: build-windows:
name: Build Windows x64 internal installer name: Build Windows x64 internal installer
runs-on: windows-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -35,6 +40,11 @@ jobs:
node-version: "22" node-version: "22"
cache: "pnpm" cache: "pnpm"
- name: Install Linux cross-build dependencies
run: |
sudo apt-get update
sudo apt-get install -y nsis lld llvm clang
- name: Setup Rust - name: Setup Rust
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
@ -44,69 +54,57 @@ jobs:
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
~\.cargo\registry ~/.cargo/registry
~\.cargo\git ~/.cargo/git
src-tauri\target src-tauri/target
.xwin-cache
key: ${{ runner.os }}-internal-windows-cargo-x86_64-pc-windows-msvc-${{ env.RUST_TARGET_CACHE_VERSION }}-${{ hashFiles('src-tauri/Cargo.lock') }} key: ${{ runner.os }}-internal-windows-cargo-x86_64-pc-windows-msvc-${{ env.RUST_TARGET_CACHE_VERSION }}-${{ hashFiles('src-tauri/Cargo.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-internal-windows-cargo-x86_64-pc-windows-msvc-${{ env.RUST_TARGET_CACHE_VERSION }}- ${{ runner.os }}-internal-windows-cargo-x86_64-pc-windows-msvc-${{ env.RUST_TARGET_CACHE_VERSION }}-
- name: Cache Tauri Windows tools - name: Install cargo-xwin
uses: actions/cache@v4 run: cargo install --locked cargo-xwin
with:
path: ~\AppData\Local\tauri
key: ${{ runner.os }}-tauri-tools-nsis-3.11-nsis-tauri-utils-0.5.3
- name: Prefetch Tauri NSIS toolchain
shell: pwsh
run: ./.github/scripts/prefetch-tauri-nsis.ps1
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Clear cached Windows bundle artifacts - name: Clear cached Windows bundle artifacts
shell: pwsh
run: | run: |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "src-tauri/target/x86_64-pc-windows-msvc/release/bundle" rm -rf src-tauri/target/x86_64-pc-windows-msvc/release/bundle
- name: Set internal app version - name: Set internal app version
shell: pwsh
run: | run: |
$version = "${{ inputs.version }}" VERSION="${{ inputs.version || '0.1.1' }}"
$tauri = Get-Content "src-tauri/tauri.conf.json" | ConvertFrom-Json jq --arg v "$VERSION" '.version = $v' src-tauri/tauri.conf.json > tmp.json && mv tmp.json src-tauri/tauri.conf.json
$tauri.version = $version sed -i "s/^version = \".*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml
$tauri | ConvertTo-Json -Depth 100 | Set-Content "src-tauri/tauri.conf.json"
(Get-Content "src-tauri/Cargo.toml") -replace '^version = ".*"$', "version = `"$version`"" | Set-Content "src-tauri/Cargo.toml"
- name: Build unsigned NSIS installer for internal testing - name: Build unsigned NSIS installer for internal testing
shell: pwsh
env: env:
VITE_SENTRY_DSN: "" VITE_SENTRY_DSN: ""
SENTRY_DSN: "" SENTRY_DSN: ""
VITE_POSTHOG_KEY: "" VITE_POSTHOG_KEY: ""
VITE_POSTHOG_HOST: "" VITE_POSTHOG_HOST: ""
XWIN_CACHE_DIR: ${{ github.workspace }}/.xwin-cache
run: | run: |
pnpm tauri build --target x86_64-pc-windows-msvc --bundles nsis pnpm tauri build --runner cargo-xwin --target x86_64-pc-windows-msvc --bundles nsis
- name: Validate installer - name: Validate installer
shell: pwsh shell: bash
run: | run: |
$bundleDir = "src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis" shopt -s nullglob
$installers = @(Get-ChildItem -Path $bundleDir -Filter "*-setup.exe" -File -ErrorAction SilentlyContinue) installers=(src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*-setup.exe)
if ($installers.Count -eq 0) { if [ ${#installers[@]} -eq 0 ]; then
throw "Windows build produced no NSIS setup executable." echo "::error::Windows build produced no NSIS setup executable."
} exit 1
foreach ($installer in $installers) { fi
if ($installer.Name -notlike "*${{ inputs.version }}*") { for installer in "${installers[@]}"; do
throw "Windows installer has unexpected version in filename: $($installer.Name)" echo "Built Windows internal installer: $installer"
} done
Write-Host "Built Windows internal installer: $($installer.FullName)"
}
- name: Upload Windows internal installer - name: Upload Windows internal installer
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ${{ inputs.artifact_name }} name: ${{ inputs.artifact_name || 'Guanghu-Windows-x64-internal' }}
path: src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*-setup.exe path: src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*-setup.exe
if-no-files-found: error if-no-files-found: error
retention-days: 7 retention-days: 7