From c545aba0bca1c6aae041480a300c9a47411fc713 Mon Sep 17 00:00:00 2001 From: kev1n77 <59403997+kev1n77@users.noreply.github.com> Date: Fri, 4 Dec 2026 23:22:19 +0800 Subject: [PATCH] fix(ci): sign and publish the Windows desktop installer --- .github/workflows/desktop-package.yml | 96 ++++++++++++++++++++++++++- docs/development/releasing.md | 13 +++- scripts/check-github-config.test.mjs | 33 +++++++++ 3 files changed, 138 insertions(+), 4 deletions(-) diff --git a/.github/workflows/desktop-package.yml b/.github/workflows/desktop-package.yml index 88d993a7cf..54b251377e 100644 --- a/.github/workflows/desktop-package.yml +++ b/.github/workflows/desktop-package.yml @@ -384,7 +384,7 @@ jobs: run: pnpm run plugin-host:prepare - name: Build desktop app - run: ${{ matrix.platform.build_command }} + run: ${{ matrix.platform.build_command }}${{ runner.os == 'Windows' && ' --no-installer' || '' }} - name: Connect Certum SimplySign if: runner.os == 'Windows' && steps.windows-signing.outputs.enabled == 'true' @@ -421,6 +421,58 @@ jobs: } if (-not (Test-Path $archive)) { throw "Missing Windows package archive $archive" } + - name: Build and sign Windows installer + if: runner.os == 'Windows' && steps.windows-signing.outputs.enabled == 'true' + shell: pwsh + env: + RELEASE_VERSION: ${{ needs.prepare.outputs.version }} + run: | + $ErrorActionPreference = 'Stop' + @' + import { buildWindowsInstaller } from './scripts/windows-installer.mjs'; + import { run } from './scripts/desktop-nsh-package-common.mjs'; + const result = buildWindowsInstaller({ + sourceDir: 'target/desktop-nsh/windows/OpenBitFun', + outputDir: 'target/desktop-nsh', + version: process.env.RELEASE_VERSION, + arch: 'x64', + executable: 'openbitfun-desktop.exe', + iconPath: 'src/apps/desktop/icons/openbitfun-app-icon.ico', + run, + }); + if (!result.built) throw new Error(`Cannot build Windows installer: ${result.reason}`); + '@ | node --input-type=module - + if ($LASTEXITCODE -ne 0) { throw 'Inno Setup failed to build the Windows installer.' } + $installer = "target/desktop-nsh/OpenBitFun-nsh_${env:RELEASE_VERSION}_x64-windows-installer.exe" + & ./scripts/ci/sign-windows.ps1 -Path (Resolve-Path -LiteralPath $installer) + + - name: Smoke-test the signed Windows installer + if: runner.os == 'Windows' && steps.windows-signing.outputs.enabled == 'true' + shell: pwsh + timeout-minutes: 8 + env: + RELEASE_VERSION: ${{ needs.prepare.outputs.version }} + run: | + $ErrorActionPreference = 'Stop' + $installer = "target/desktop-nsh/OpenBitFun-nsh_${env:RELEASE_VERSION}_x64-windows-installer.exe" + $location = Join-Path $env:RUNNER_TEMP 'OpenBitFun installer smoke' + $setup = Start-Process -FilePath $installer -Wait -PassThru -ArgumentList @( + '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/CURRENTUSER', "/DIR=`"$location`"" + ) + if ($setup.ExitCode -ne 0) { throw "Windows installer exited with $($setup.ExitCode)." } + try { + foreach ($file in @('openbitfun-desktop.exe', 'openbitfun_desktop_lib.dll')) { + & ./scripts/ci/sign-windows.ps1 -VerifyOnly -Path (Join-Path $location $file) + } + node tests/e2e/native/smoke.mjs --app (Join-Path $location 'openbitfun-desktop.exe') + if ($LASTEXITCODE -ne 0) { throw 'The installed Windows application failed its smoke test.' } + } finally { + $uninstaller = Join-Path $location 'unins000.exe' + if (Test-Path -LiteralPath $uninstaller) { + Start-Process -FilePath $uninstaller -Wait -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART' + } + } + - name: Sign, notarize and archive macOS release if: runner.os == 'macOS' shell: bash @@ -481,8 +533,47 @@ jobs: path: | target/*/release/bundle target/desktop-nsh/OpenBitFun-nsh_*-windows.zip + target/desktop-nsh/OpenBitFun-nsh_*-windows-installer.exe target/desktop-nsh/OpenBitFun-nsh_*-linux.tar.gz + sign-windows-installer: + name: Sign Windows Installer Recovery Asset + needs: [prepare, package] + if: needs.prepare.outputs.target_platform == 'windows-x64' && needs.prepare.outputs.upload_to_release == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + env: + INSTALLER: OpenBitFun-nsh_${{ needs.prepare.outputs.version }}_x64-windows-installer.exe + steps: + - uses: actions/checkout@v5 + + - uses: actions/download-artifact@v7 + with: + name: openbitfun-${{ needs.prepare.outputs.release_tag }}-windows-x64-bundle + path: windows-bundle + + - name: Sign and verify Windows installer recovery asset + shell: bash + env: + OPENBITFUN_SIGNING_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + OPENBITFUN_SIGNING_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + OPENBITFUN_SIGNING_PUBKEY: ${{ secrets.TAURI_UPDATER_PUBKEY }} + run: | + set -euo pipefail + mapfile -t matches < <(find windows-bundle -type f -name "$INSTALLER") + [[ "${#matches[@]}" -eq 1 ]] + mkdir windows-installer + cp "${matches[0]}" "windows-installer/$INSTALLER" + bash scripts/sign-release-assets.sh "windows-installer/$INSTALLER" + test -s "windows-installer/$INSTALLER.sig" + + - uses: actions/upload-artifact@v6 + with: + name: openbitfun-${{ needs.prepare.outputs.release_tag }}-windows-x64-installer + path: windows-installer/ + if-no-files-found: error + recover-macos: name: Package (${{ matrix.platform.name }}) needs: prepare @@ -889,6 +980,7 @@ jobs: mapfile -t assets < <( find release-assets -type f -not -path '*.app/*' \ \( -name '*.dmg' -o -name 'OpenBitFun-nsh_*-windows.zip' \ + -o -name 'OpenBitFun-nsh_*-windows-installer.exe' \ -o -name 'OpenBitFun-nsh_*-linux.tar.gz' \) | sort ) if [[ "${#assets[@]}" -eq 0 ]]; then @@ -966,6 +1058,8 @@ jobs: release-assets/**/*.dmg.sig \ release-assets/**/OpenBitFun-nsh_*-windows.zip \ release-assets/**/OpenBitFun-nsh_*-windows.zip.sig \ + release-assets/**/OpenBitFun-nsh_*-windows-installer.exe \ + release-assets/**/OpenBitFun-nsh_*-windows-installer.exe.sig \ release-assets/**/OpenBitFun-nsh_*-linux.tar.gz \ release-assets/**/OpenBitFun-nsh_*-linux.tar.gz.sig \ release-assets/minisign.pub \ diff --git a/docs/development/releasing.md b/docs/development/releasing.md index ecb30dcab6..e49cacb600 100644 --- a/docs/development/releasing.md +++ b/docs/development/releasing.md @@ -34,7 +34,7 @@ backend (`scripts/ci/desktop-release-env.mjs`). Each release publishes: | Platform | Release assets | In-app update | |---|---|---| | macOS arm64 / x64 | `OpenBitFun__.dmg` (+ `.sig`); `OpenBitFun-nsh__.app.tar.gz` (+ `.sig`) | yes, from the `.app.tar.gz` | -| Windows x64 | `OpenBitFun-nsh__x64-windows.zip` (+ `.sig`) | not yet: manual download | +| Windows x64 | `OpenBitFun-nsh__x64-windows-installer.exe` and `OpenBitFun-nsh__x64-windows.zip` (both with `.sig`) | not yet: manual download | | Linux x64 / arm64 | `OpenBitFun-nsh__-linux.tar.gz` (+ `.sig`) | not yet: manual download | `scripts/ci/package-native-macos-release.sh` signs the app with Developer ID @@ -128,7 +128,7 @@ For an existing immutable tag, dispatch `Desktop Package` from the current `main` workflow with `target_platform=macos-arm64`, `macos-x64`, or `windows-x64`. Keep `release_channel` equal to the original build and enable `upload_to_release` to require release signing and produce updater signatures. This target option -uploads only the selected platform's Actions artifact; it never publishes a +uploads Actions artifacts for the selected platform; it never publishes a GitHub Release, rebuilds Linux binaries, pushes the Relay image, or changes an update feed. `all`, the default, retains the complete release gate. @@ -137,7 +137,14 @@ finish alongside an existing full matrix without cancelling it. Build source still resolves to the original tag SHA. macOS signature verification uses the pinned workflow revision, allowing verification fixes to apply without moving that tag. -After recovery, dispatch the same workflow with `target_platform=all`, the + +To add a Windows installer to an already public release, use `target_platform=windows-x64` +with `upload_to_release=true`. After the installer passes Authenticode verification +and the install-and-launch test, download the `openbitfun--windows-x64-installer` +artifact and attach its `.exe` and `.sig` to that release. The installer recovery +artifact contains only those two files. + +To finalize a complete release after recovery, dispatch the same workflow with `target_platform=all`, the original tag/channel, `upload_to_release=true`, and `artifact_run_ids` containing the original and recovery run IDs separated by commas. This skips all builders and runs the normal full release publisher. It requires exactly one artifact diff --git a/scripts/check-github-config.test.mjs b/scripts/check-github-config.test.mjs index 1cf178f018..2e93132e22 100644 --- a/scripts/check-github-config.test.mjs +++ b/scripts/check-github-config.test.mjs @@ -1739,6 +1739,39 @@ test('Desktop recovery selects one platform and cannot publish an incomplete rel assert.doesNotMatch(JSON.stringify(recover.steps), /desktop:build|cargo build|pnpm install/); }); +test('Desktop releases publish a verified Inno Setup installer alongside the Windows update ZIP', () => { + const { jobs } = yaml.parse(readFileSync(path.join(repoRoot, '.github/workflows/desktop-package.yml'), 'utf8')); + const steps = jobs.package.steps; + const step = (name) => steps.find((entry) => entry.name === name); + const build = step('Build desktop app'); + const archive = step('Sign and archive Windows package'); + const installer = step('Build and sign Windows installer'); + const smoke = step('Smoke-test the signed Windows installer'); + const upload = step('Upload bundles'); + const order = [build, archive, installer, smoke, upload].map((entry) => steps.indexOf(entry)); + assert.ok(order.every((index, i) => index >= 0 && (i === 0 || index > order[i - 1]))); + assert.match(build.run, /runner\.os == 'Windows' && ' --no-installer'/); + const requireCert = "runner.os == 'Windows' && steps.windows-signing.outputs.enabled == 'true'"; + assert.equal(installer.if, requireCert); + assert.equal(smoke.if, requireCert); + assert.ok(installer.run.indexOf('buildWindowsInstaller({') < installer.run.indexOf('sign-windows.ps1')); + assert.match(smoke.run, /Start-Process -FilePath \$installer/); + assert.match(smoke.run, /sign-windows\.ps1 -VerifyOnly/); + assert.match(smoke.run, /smoke\.mjs --app \(Join-Path \$location 'openbitfun-desktop\.exe'\)/); + assert.match(upload.with.path, /OpenBitFun-nsh_\*-windows-installer\.exe/); + + const recovery = jobs['sign-windows-installer']; + assert.deepEqual(recovery.needs, ['prepare', 'package']); + assert.equal(recovery.if, "needs.prepare.outputs.target_platform == 'windows-x64' && needs.prepare.outputs.upload_to_release == 'true'"); + assert.equal(recovery.permissions.contents, 'read'); + assert.match(recovery.steps[2].run, /sign-release-assets\.sh[^\n]+\n.*test -s.*\.sig/); + assert.match(recovery.steps[3].with.name, /-windows-x64-installer$/); + + const release = jobs['upload-release-assets'].steps; + assert.match(release.find((entry) => entry.name === 'Sign installer packages').run, /OpenBitFun-nsh_\*-windows-installer\.exe/); + assert.match(release.find((entry) => entry.name === 'Stage release assets').run, /windows-installer\.exe[^\n]*\n[^\n]+windows-installer\.exe\.sig/); +}); + test('Mac verification recovery requires the exact failed trusted producer and unexpired checkpoint', async () => { const { planMacVerificationRecovery } = await import('./restore-macos-verification-bundle.mjs'); const repo = 'GCWing/OpenBitFun', tag = 'v1.0.6', platform = 'macos-x64';