ci: cross-build windows internal installer
Some checks failed
Build Windows Internal Installer / Build Windows x64 internal installer (push) Has been cancelled
Some checks failed
Build Windows Internal Installer / Build Windows x64 internal installer (push) Has been cancelled
This commit is contained in:
parent
d8a0fb9817
commit
d10824e685
70
.github/workflows/build-windows-manual.yml
vendored
70
.github/workflows/build-windows-manual.yml
vendored
@ -1,6 +1,11 @@
|
||||
name: Build Windows Internal Installer
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- ".github/workflows/build-windows-manual.yml"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
@ -19,7 +24,7 @@ env:
|
||||
jobs:
|
||||
build-windows:
|
||||
name: Build Windows x64 internal installer
|
||||
runs-on: windows-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -35,6 +40,11 @@ jobs:
|
||||
node-version: "22"
|
||||
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
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
@ -44,69 +54,57 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~\.cargo\registry
|
||||
~\.cargo\git
|
||||
src-tauri\target
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
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') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-internal-windows-cargo-x86_64-pc-windows-msvc-${{ env.RUST_TARGET_CACHE_VERSION }}-
|
||||
|
||||
- name: Cache Tauri Windows tools
|
||||
uses: actions/cache@v4
|
||||
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 cargo-xwin
|
||||
run: cargo install --locked cargo-xwin
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Clear cached Windows bundle artifacts
|
||||
shell: pwsh
|
||||
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
|
||||
shell: pwsh
|
||||
run: |
|
||||
$version = "${{ inputs.version }}"
|
||||
$tauri = Get-Content "src-tauri/tauri.conf.json" | ConvertFrom-Json
|
||||
$tauri.version = $version
|
||||
$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"
|
||||
VERSION="${{ inputs.version || '0.1.1' }}"
|
||||
jq --arg v "$VERSION" '.version = $v' src-tauri/tauri.conf.json > tmp.json && mv tmp.json src-tauri/tauri.conf.json
|
||||
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" src-tauri/Cargo.toml
|
||||
|
||||
- name: Build unsigned NSIS installer for internal testing
|
||||
shell: pwsh
|
||||
env:
|
||||
VITE_SENTRY_DSN: ""
|
||||
SENTRY_DSN: ""
|
||||
VITE_POSTHOG_KEY: ""
|
||||
VITE_POSTHOG_HOST: ""
|
||||
XWIN_CACHE_DIR: ${{ github.workspace }}/.xwin-cache
|
||||
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
|
||||
shell: pwsh
|
||||
shell: bash
|
||||
run: |
|
||||
$bundleDir = "src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis"
|
||||
$installers = @(Get-ChildItem -Path $bundleDir -Filter "*-setup.exe" -File -ErrorAction SilentlyContinue)
|
||||
if ($installers.Count -eq 0) {
|
||||
throw "Windows build produced no NSIS setup executable."
|
||||
}
|
||||
foreach ($installer in $installers) {
|
||||
if ($installer.Name -notlike "*${{ inputs.version }}*") {
|
||||
throw "Windows installer has unexpected version in filename: $($installer.Name)"
|
||||
}
|
||||
Write-Host "Built Windows internal installer: $($installer.FullName)"
|
||||
}
|
||||
shopt -s nullglob
|
||||
installers=(src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*-setup.exe)
|
||||
if [ ${#installers[@]} -eq 0 ]; then
|
||||
echo "::error::Windows build produced no NSIS setup executable."
|
||||
exit 1
|
||||
fi
|
||||
for installer in "${installers[@]}"; do
|
||||
echo "Built Windows internal installer: $installer"
|
||||
done
|
||||
|
||||
- name: Upload Windows internal installer
|
||||
uses: actions/upload-artifact@v4
|
||||
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
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user