[Single] Build Windows NSIS #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "[Single] Build Windows NSIS" | |
on: | |
workflow_dispatch: | |
inputs: | |
portable: | |
description: "Build Portable pkg" | |
required: true | |
type: boolean | |
default: false | |
fixed-webview: | |
description: "Fixed WebView" | |
required: true | |
type: boolean | |
default: false | |
nightly: | |
description: "Nightly prepare" | |
required: true | |
type: boolean | |
default: false | |
tag: | |
description: "Release Tag" | |
required: true | |
type: string | |
arch: | |
type: choice | |
description: "build arch target" | |
required: true | |
default: "x86_64" | |
options: | |
- x86_64 | |
- i686 | |
- aarch64 | |
workflow_call: | |
inputs: | |
portable: | |
description: "Build Portable pkg" | |
required: true | |
type: boolean | |
default: false | |
fixed-webview: | |
description: "Fixed WebView" | |
required: true | |
type: boolean | |
default: false | |
nightly: | |
description: "Nightly prepare" | |
required: true | |
type: boolean | |
default: false | |
tag: | |
description: "Release Tag" | |
required: true | |
type: string | |
arch: | |
type: string | |
description: "build arch target" | |
required: true | |
default: "x86_64" | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Rust stable | |
run: | | |
rustup install stable --profile minimal --no-self-update | |
rustup default stable | |
- name: Setup Rust target | |
if: ${{ inputs.arch != 'x86_64' }} | |
run: | | |
rustup target add ${{ inputs.arch }}-pc-windows-msvc | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: "./backend/" | |
prefix-key: "rust-stable" | |
key: windows-latest | |
shared-key: "release" | |
- name: Install Node latest | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
run_install: false | |
- name: Install Node.js dependencies | |
run: | | |
pnpm i | |
- name: Prepare sidecars and resources | |
run: | | |
$condition = '${{ inputs.arch }}' | |
switch ($condition) { | |
'x86_64' { | |
pnpm check | |
} | |
'i686' { | |
pnpm check --arch ia32 --sidecar-host i686-pc-windows-msvc | |
} | |
'aarch64' { | |
pnpm check --arch arm64 --sidecar-host aarch64-pc-windows-msvc | |
} | |
} | |
- name: Download fixed WebView | |
if: ${{ inputs.fixed-webview == true }} | |
run: | | |
$condition = '${{ inputs.arch }}' | |
switch ($condition) { | |
'x86_64' { | |
$arch= 'x64' | |
} | |
'i686' { | |
$arch = 'x86' | |
} | |
'aarch64' { | |
$arch = 'arm64' | |
} | |
} | |
$version = '127.0.2651.105' | |
$uri = "https://github.com/westinyang/WebView2RuntimeArchive/releases/download/$version/Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab" | |
$outfile = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab" | |
echo "Downloading $uri to $outfile" | |
invoke-webrequest -uri $uri -outfile $outfile | |
echo "Download finished, attempting to extract" | |
expand.exe $outfile -F:* ./backend/tauri | |
echo "Extraction finished" | |
- name: Prepare (Windows NSIS and Portable) | |
if: ${{ inputs.fixed-webview == false }} | |
run: ${{ inputs.nightly == true && 'pnpm prepare:nightly --nsis' || 'pnpm prepare:release --nsis' }} | |
- name: Prepare (Windows NSIS and Portable) with fixed WebView | |
if: ${{ inputs.fixed-webview == true }} | |
run: ${{ inputs.nightly == true && 'pnpm prepare:nightly --nsis --fixed-webview' || 'pnpm prepare:release --nsis --fixed-webview' }} | |
- name: Build UI | |
run: | | |
pnpm -F ui build | |
# TODO: optimize strategy | |
- name: Tauri build x86_64 | |
if: ${{ inputs.arch == 'x86_64' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | |
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }} | |
run: | | |
pnpm tauri build ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json' || '-f default-meta' }} | |
- name: Tauri build i686 | |
if: ${{ inputs.arch == 'i686' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | |
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }} | |
run: | | |
pnpm tauri build ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json --target i686-pc-windows-msvc' || '-f default-meta --target i686-pc-windows-msvc' }} | |
- name: Tauri build arm64 | |
if: ${{ inputs.arch == 'aarch64' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | |
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }} | |
run: | | |
pnpm tauri build ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json --target aarch64-pc-windows-msvc' || '-f default-meta --target aarch64-pc-windows-msvc' }} | |
- name: Rename fixed webview bundle name | |
if: ${{ inputs.fixed-webview == true }} | |
run: | | |
$files = Get-ChildItem -Path "./backend/target" -Recurse -Include "*.exe", "*.zip", "*.zip.sig" | Where-Object { $_.FullName -like "*\bundle\*" } | |
$condition = '${{ inputs.arch }}' | |
switch ($condition) { | |
'x86_64' { | |
$arch= 'x64' | |
} | |
'i686' { | |
$arch = 'x86' | |
} | |
'aarch64' { | |
$arch = 'arm64' | |
} | |
} | |
foreach ($file in $files) { | |
echo "Renaming $file.FullName" | |
$newname = $file.FullName -replace $arch, "fixed-webview-$arch" | |
Rename-Item -Path $file.FullName -NewName $newname | |
} | |
- name: Upload to release | |
run: | | |
$files = Get-ChildItem -Path "./backend/target" -Recurse -Include "*.exe", "*.zip", "*.zip.sig" | Where-Object { $_.FullName -like "*\bundle\*" } | |
foreach ($file in $files) { | |
echo "Uploading $file.FullName" | |
gh release upload ${{ inputs.tag }} "$file.FullName" --clobber | |
} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Portable Bundle | |
if: ${{ inputs.portable == true }} | |
run: | | |
pnpm portable ${{ inputs.fixed-webview == true && '--fixed-webview' || '' }} | |
env: | |
RUST_ARCH: ${{ inputs.arch }} | |
TAG_NAME: ${{ inputs.tag }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | |
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }} | |
VITE_WIN_PORTABLE: 1 |