|
| 1 | +name: Windows Build (NSIS) |
| 2 | + |
| 3 | +# Builds the Windows installer in a clean Windows 2022 runner. |
| 4 | +# This is opt-in: trigger manually via the "Run workflow" button on GitHub, |
| 5 | +# or push a tag matching `v*` to produce a release artifact. |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + sign: |
| 11 | + description: "Sign the installer (requires repo secrets to be configured)" |
| 12 | + required: false |
| 13 | + default: "false" |
| 14 | + push: |
| 15 | + tags: |
| 16 | + - "v*" |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-nsis: |
| 23 | + name: Build & package (x86_64-pc-windows-msvc) |
| 24 | + runs-on: windows-2022 |
| 25 | + timeout-minutes: 90 |
| 26 | + defaults: |
| 27 | + run: |
| 28 | + shell: pwsh |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + submodules: recursive |
| 35 | + |
| 36 | + - name: Set up Node.js |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: "20" |
| 40 | + cache: "npm" |
| 41 | + cache-dependency-path: | |
| 42 | + desktop/package-lock.json |
| 43 | + desktop/app/package-lock.json |
| 44 | +
|
| 45 | + - name: Set up Rust toolchain |
| 46 | + uses: dtolnay/rust-toolchain@stable |
| 47 | + with: |
| 48 | + targets: x86_64-pc-windows-msvc |
| 49 | + |
| 50 | + - name: Cache Rust build artifacts |
| 51 | + uses: Swatinem/rust-cache@v2 |
| 52 | + with: |
| 53 | + workspaces: desktop/src-tauri |
| 54 | + |
| 55 | + - name: Install uv |
| 56 | + uses: astral-sh/setup-uv@v3 |
| 57 | + with: |
| 58 | + enable-cache: true |
| 59 | + |
| 60 | + - name: Install npm dependencies |
| 61 | + working-directory: desktop |
| 62 | + run: | |
| 63 | + npm install |
| 64 | + npm --prefix app install |
| 65 | +
|
| 66 | + - name: Build (and optionally sign) NSIS installer |
| 67 | + env: |
| 68 | + SIGNTOOL_CERT_BASE64: ${{ secrets.SIGNTOOL_CERT_BASE64 }} |
| 69 | + SIGNTOOL_CERT_PASSWORD: ${{ secrets.SIGNTOOL_CERT_PASSWORD }} |
| 70 | + SIGNTOOL_TIMESTAMP_URL: ${{ secrets.SIGNTOOL_TIMESTAMP_URL }} |
| 71 | + run: | |
| 72 | + $shouldSign = ($env:GITHUB_EVENT_NAME -eq 'push') -or ('${{ github.event.inputs.sign }}' -eq 'true') |
| 73 | + if ($shouldSign -and $env:SIGNTOOL_CERT_BASE64) { |
| 74 | + $pfxPath = Join-Path $env:RUNNER_TEMP "voca-signing.pfx" |
| 75 | + [System.IO.File]::WriteAllBytes( |
| 76 | + $pfxPath, |
| 77 | + [System.Convert]::FromBase64String($env:SIGNTOOL_CERT_BASE64) |
| 78 | + ) |
| 79 | + $env:SIGNTOOL_CERT_PATH = $pfxPath |
| 80 | + pwsh ./desktop/scripts/build-nsis-local.ps1 |
| 81 | + } else { |
| 82 | + if ($shouldSign) { |
| 83 | + Write-Host "::warning ::Signing requested but SIGNTOOL_CERT_BASE64 secret is missing; building unsigned." |
| 84 | + } |
| 85 | + pwsh ./desktop/scripts/build-nsis-local.ps1 -SkipSign |
| 86 | + } |
| 87 | +
|
| 88 | + - name: Collect installer |
| 89 | + id: collect |
| 90 | + working-directory: desktop/src-tauri/target/release/bundle/nsis |
| 91 | + run: | |
| 92 | + $installer = Get-ChildItem -Filter "Voca_*-setup.exe" | Select-Object -First 1 |
| 93 | + if (-not $installer) { |
| 94 | + Write-Error "No NSIS installer found" |
| 95 | + exit 1 |
| 96 | + } |
| 97 | + "installer_path=$($installer.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 98 | + "installer_name=$($installer.Name)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 99 | +
|
| 100 | + - name: Upload installer artifact |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: ${{ steps.collect.outputs.installer_name }} |
| 104 | + path: ${{ steps.collect.outputs.installer_path }} |
| 105 | + if-no-files-found: error |
| 106 | + retention-days: 14 |
0 commit comments