Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

ci(release): signing lanes for Windows and macOS that stay off without their secrets

purple0b70eadb779c
diff --git a/.github/actions/windows-signpath/action.yml b/.github/actions/windows-signpath/action.yml
new file mode 100644
index 00000000..859a259c
--- /dev/null
+++ b/.github/actions/windows-signpath/action.yml
@@ -0,0 +1,208 @@
+name: Build and sign the Windows installers with SignPath
+description: >-
+ Builds the app, has SignPath sign the app binary, packs the installers
+ around the signed binary, has SignPath sign the installers, and writes the
+ updater signatures over the signed files. Publishes nothing.
+
+# SignPath signs artifacts that were uploaded to GitHub, after the build;
+# Tauri would sign during the build. So the build is split in two and SignPath
+# is asked twice:
+#
+# 1. `tauri build --no-bundle` compiles the app and stops.
+# 2. Request one (artifact configuration "windows-app"): the app binary.
+# 3. `tauri bundle` packs the NSIS installer and the MSI around the signed
+# binary. It does not compile again and does not change the binary
+# (read at tauri-cli 2.10.1; the binary is compared after each run).
+# 4. Request two (artifact configuration "windows-installers"): both
+# installers. SignPath cannot look inside an NSIS installer, which is
+# why the binary had to be signed first.
+# 5. The updater archives and their minisign signatures are made from the
+# signed installers, so the updater checks the same bytes a user
+# downloads.
+#
+# Every other file in the installers stays unsigned on purpose: the llama.cpp
+# server and its libraries are built from upstream source, and the terms of
+# the SignPath Foundation allow its certificate for this project's own
+# binaries only (https://signpath.org/terms, read 2026-10-08).
+#
+# The caller must have checked out the repository, installed Node, Rust and
+# the npm dependencies, and built the llama.cpp sidecar. Every job of the
+# workflow has to run on a GitHub-hosted runner, or SignPath refuses.
+#
+# Used by release.yml (publishes the result) and signpath-probe.yml (keeps it
+# as a workflow artifact).
+
+inputs:
+ api-token:
+ description: API token of the SignPath CI user that may submit to the signing policy.
+ required: true
+ organization-id:
+ description: SignPath organization ID.
+ required: true
+ project-slug:
+ description: SignPath project slug.
+ required: true
+ signing-policy-slug:
+ description: SignPath signing policy slug, for example test-signing or release-signing.
+ required: true
+ app-artifact-configuration-slug:
+ description: Slug of the artifact configuration in .signpath/artifact-configurations/windows-app.xml.
+ default: windows-app
+ installers-artifact-configuration-slug:
+ description: Slug of the artifact configuration in .signpath/artifact-configurations/windows-installers.xml.
+ default: windows-installers
+ wait-seconds:
+ description: >-
+ How long each signing request may wait for its result. A policy with
+ manual approval waits for a person, twice per build.
+ default: '7200'
+ expected-publisher:
+ description: Text the subject of the signing certificate must contain. Empty skips the check.
+ default: ''
+ allow-test-certificate:
+ description: Accept a self-signed certificate that Windows does not trust. Only for the test-signing policy.
+ default: 'false'
+ updater-private-key:
+ description: Tauri updater private key (minisign) that signs the updater files.
+ required: true
+ updater-private-key-password:
+ description: Password of the updater private key.
+ default: ''
+
+outputs:
+ dist:
+ description: Directory with the signed installers, the updater archives and their .sig files, under their release asset names.
+ value: ${{ steps.updater.outputs.dir }}
+ publisher:
+ description: Subject of the certificate that signed the installers.
+ value: ${{ steps.verify.outputs.publisher }}
+ app-signing-request:
+ description: URL of the first signing request in SignPath.
+ value: ${{ steps.sign-app.outputs.signing-request-web-url }}
+ installers-signing-request:
+ description: URL of the second signing request in SignPath.
+ value: ${{ steps.sign-installers.outputs.signing-request-web-url }}
+
+runs:
+ using: composite
+ steps:
+ - name: Build the app without bundling
+ shell: bash
+ run: npx tauri build --no-bundle
+
+ - name: Stage the app binary for signing
+ id: stage-app
+ shell: bash
+ run: node scripts/windows-signpath.mjs stage-app "$RUNNER_TEMP/signpath/app-unsigned"
+
+ # SignPath takes its input from GitHub's artifact store, not from the
+ # runner, so that what it signs is what this workflow run produced.
+ - name: Upload the unsigned app binary
+ id: upload-app
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: windows-app-unsigned
+ path: ${{ steps.stage-app.outputs.dir }}
+ if-no-files-found: error
+ retention-days: 7
+ overwrite: true
+
+ - name: Sign the app binary (SignPath)
+ id: sign-app
+ uses: signpath/github-action-submit-signing-request@f6d04783b4569d051e0c80105fe66e82819d0092 # v3.0
+ with:
+ api-token: ${{ inputs.api-token }}
+ organization-id: ${{ inputs.organization-id }}
+ project-slug: ${{ inputs.project-slug }}
+ signing-policy-slug: ${{ inputs.signing-policy-slug }}
+ artifact-configuration-slug: ${{ inputs.app-artifact-configuration-slug }}
+ github-artifact-id: ${{ steps.upload-app.outputs.artifact-id }}
+ wait-for-completion: true
+ wait-for-completion-timeout-in-seconds: ${{ inputs.wait-seconds }}
+ output-artifact-directory: ${{ runner.temp }}/signpath/app-signed
+ parameters: |
+ version: "${{ steps.stage-app.outputs.version }}"
+
+ # One installer type per run, each around the copy of the binary that is
+ # marked for it. `check-app` fails the build if the bundler touched the
+ # signed file.
+ - name: Pack the installers around the signed app binary
+ shell: bash
+ env:
+ SIGNED: ${{ runner.temp }}/signpath/app-signed
+ run: |
+ set -euo pipefail
+ for kind in nsis msi; do
+ node scripts/windows-signpath.mjs place-app "$kind" "$SIGNED"
+ npx tauri bundle --bundles "$kind"
+ node scripts/windows-signpath.mjs check-app "$kind" "$SIGNED"
+ done
+
+ - name: Stage the installers for signing
+ id: stage-installers
+ shell: bash
+ run: node scripts/windows-signpath.mjs stage-installers "$RUNNER_TEMP/signpath/installers-unsigned"
+
+ - name: Upload the unsigned installers
+ id: upload-installers
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: windows-installers-unsigned
+ path: ${{ steps.stage-installers.outputs.dir }}
+ if-no-files-found: error
+ retention-days: 7
+ overwrite: true
+
+ - name: Sign the installers (SignPath)
+ id: sign-installers
+ uses: signpath/github-action-submit-signing-request@f6d04783b4569d051e0c80105fe66e82819d0092 # v3.0
+ with:
+ api-token: ${{ inputs.api-token }}
+ organization-id: ${{ inputs.organization-id }}
+ project-slug: ${{ inputs.project-slug }}
+ signing-policy-slug: ${{ inputs.signing-policy-slug }}
+ artifact-configuration-slug: ${{ inputs.installers-artifact-configuration-slug }}
+ github-artifact-id: ${{ steps.upload-installers.outputs.artifact-id }}
+ wait-for-completion: true
+ wait-for-completion-timeout-in-seconds: ${{ inputs.wait-seconds }}
+ output-artifact-directory: ${{ runner.temp }}/signpath/installers-signed
+ parameters: |
+ version: "${{ steps.stage-app.outputs.version }}"
+
+ # The updater signature has to cover the file a user downloads. That file
+ # exists only now, so the .sig files are written here and not by the
+ # bundler.
+ - name: Write the updater archives and signatures over the signed installers
+ id: updater
+ shell: pwsh
+ env:
+ TAURI_SIGNING_PRIVATE_KEY: ${{ inputs.updater-private-key }}
+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ inputs.updater-private-key-password }}
+ run: |
+ $signed = Join-Path $env:RUNNER_TEMP 'signpath/installers-signed'
+ $dist = Join-Path $env:RUNNER_TEMP 'signpath/dist'
+ node scripts/windows-signpath.mjs updater-artifacts $signed $dist
+ if ($LASTEXITCODE -ne 0) { throw "the updater archives could not be written" }
+ foreach ($file in @(Get-ChildItem -File -Path $dist)) {
+ npx tauri signer sign $file.FullName | Out-Null
+ if ($LASTEXITCODE -ne 0) { throw "tauri signer sign failed for $($file.Name)" }
+ if (-not (Test-Path "$($file.FullName).sig")) { throw "no updater signature was written for $($file.Name)" }
+ }
+ Get-ChildItem -File -Path $dist | Format-Table Name, Length
+
+ - name: Verify the signatures
+ id: verify
+ shell: pwsh
+ env:
+ DIST: ${{ steps.updater.outputs.dir }}
+ EXPECTED_PUBLISHER: ${{ inputs.expected-publisher }}
+ ALLOW_TEST_CERTIFICATE: ${{ inputs.allow-test-certificate }}
+ APP_BINARY: ${{ steps.stage-app.outputs.binary }}
+ run: |
+ $arguments = @{
+ BundleRoot = $env:DIST
+ ExpectedPublisher = $env:EXPECTED_PUBLISHER
+ SignedExecutables = @($env:APP_BINARY)
+ }
+ if ($env:ALLOW_TEST_CERTIFICATE -eq 'true') { $arguments.AllowTestCertificate = $true }
+ ./scripts/windows-signing-verify.ps1 @arguments
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index dcbafabd..239c9893 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -48,6 +48,14 @@ env:
STORIES260K_REVISION: '499bc8821c6b12b4e53c5bffcb21ec206f212d81'
STORIES260K_SHA256: '270cba1bd5109f42d03350f60406024560464db173c0e387d91f0426d3bd256d'
+ # Windows code signing (Azure Artifact Signing), used only when the signing
+ # secrets exist: the SignTool plug-in Microsoft publishes as the NuGet package
+ # Microsoft.ArtifactSigning.Client, pinned by version and by the sha256 of the
+ # .nupkg file, both read from api.nuget.org on 2026-10-08. Bump both together:
+ # https://api.nuget.org/v3-flatcontainer/microsoft.artifactsigning.client/index.json
+ ARTIFACT_SIGNING_CLIENT_VERSION: '1.0.146'
+ ARTIFACT_SIGNING_CLIENT_SHA256: '7761e5d8f31e54b764da21d33cd8b0a2940e1b05526c7dfcb5e94b0431426f70'
+
jobs:
# The Latest flag comes off FIRST, before anything is gated or built.
#
@@ -90,6 +98,39 @@ jobs:
PUBLISHED_TAG: ${{ github.event.release.tag_name }}
run: node scripts/enforce-prerelease.mjs
+ # Code signing is opt-in by secrets. This repository ships unsigned Windows
+ # and Linux installers and no macOS build, and it keeps doing exactly that
+ # until the secrets of a signing lane are entered: then that lane switches
+ # on with no further change to this file. A fork has none of the secrets, so
+ # a fork builds what it builds today.
+ #
+ # `secrets` cannot be read in a job-level `if:`, so this job turns "are the
+ # secrets there" into a plain output the macOS job can be conditioned on. The
+ # values themselves never leave the step: scripts/signing-config.sh only
+ # tests them for presence. A half-filled set is a warning on the run and
+ # counts as absent.
+ signing-config:
+ runs-on: ubuntu-22.04
+ outputs:
+ macos: ${{ steps.detect.outputs.macos }}
+ macos_notary: ${{ steps.detect.outputs.macos_notary }}
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
+ with:
+ ref: ${{ github.event.release.tag_name || github.event.inputs.tag }}
+ - name: Which signing secrets are present
+ id: detect
+ env:
+ APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
+ APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
+ APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
+ APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
+ APPLE_API_KEY_P8: ${{ secrets.APPLE_API_KEY_P8 }}
+ APPLE_ID: ${{ secrets.APPLE_ID }}
+ APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
+ APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
+ run: bash scripts/signing-config.sh macos
+
# A build is not a decision — and neither is a green master. Until this job
# existed, `release.yml` typechecked nothing, ran no test and no lint: any
# commit that happened to sit on master when someone clicked "Publish release"
@@ -115,7 +156,13 @@ jobs:
# signs the bundle and builds every installer target (NSIS, MSI, deb,
# AppImage) that ci.yml's own tauri-build does not, so its ceiling is
# wider than that job's 60 minutes rather than equal to it.
- timeout-minutes: 90
+ #
+ # The SignPath lane (Windows only) waits for a person to approve two
+ # signing requests, so that leg gets the six hours a hosted runner allows.
+ # The signing policy is the last of the SignPath values to be entered,
+ # the one that switches the lane on for releases; without it the
+ # expression is 90 for every leg, as before.
+ timeout-minutes: ${{ matrix.platform == 'windows-latest' && vars.SIGNPATH_SIGNING_POLICY_SLUG != '' && 360 || 90 }}
strategy:
fail-fast: false
matrix:
@@ -128,9 +175,10 @@ jobs:
args: ''
rust_targets: ''
sidecar_triple: x86_64-pc-windows-msvc
- # No macOS lane: LU ships Windows + Linux only (the 2.5.7 mac assets
- # were unsigned/ad-hoc and pulled post-release). Re-add a macos-14
- # entry here once Apple Developer ID signing creds land as secrets.
+ # No macOS entry in this matrix: the 2.5.7 mac assets were ad hoc
+ # signed and pulled after the release (c1644d9a). macOS is built by
+ # the build-macos job below, and only as a Developer ID signed and
+ # notarized build, which needs the Apple secrets.
runs-on: ${{ matrix.platform }}
@@ -498,12 +546,60 @@ jobs:
- name: Install npm dependencies
run: npm ci
+ # ── Windows code signing, only with the secrets of one lane ──────────
+ # Two lanes, and at most one of them signs a release:
+ # - Azure Artifact Signing signs inside `tauri build`.
+ # - SignPath signs uploaded artifacts after the build, so that lane
+ # replaces the build step below with its own (see the action).
+ # Without the values of either lane the detect step answers false twice,
+ # every signing step is skipped, and the build below gets the same
+ # arguments it always got: unsigned installers, as before. With both
+ # lanes complete the detect step fails the run.
+ - name: Which Windows signing secrets are present
+ id: signcfg
+ if: matrix.platform == 'windows-latest'
+ shell: bash
+ env:
+ AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
+ AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
+ AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
+ ARTIFACT_SIGNING_ENDPOINT: ${{ secrets.ARTIFACT_SIGNING_ENDPOINT }}
+ ARTIFACT_SIGNING_ACCOUNT: ${{ secrets.ARTIFACT_SIGNING_ACCOUNT }}
+ ARTIFACT_SIGNING_PROFILE: ${{ secrets.ARTIFACT_SIGNING_PROFILE }}
+ SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }}
+ SIGNPATH_ORGANIZATION_ID: ${{ vars.SIGNPATH_ORGANIZATION_ID }}
+ SIGNPATH_PROJECT_SLUG: ${{ vars.SIGNPATH_PROJECT_SLUG }}
+ SIGNPATH_SIGNING_POLICY_SLUG: ${{ vars.SIGNPATH_SIGNING_POLICY_SLUG }}
+ run: bash scripts/signing-config.sh windows
+
+ - name: Configure Windows code signing (Azure Artifact Signing)
+ id: winsign
+ if: matrix.platform == 'windows-latest' && steps.signcfg.outputs.windows == 'true'
+ shell: pwsh
+ timeout-minutes: 5
+ env:
+ ARTIFACT_SIGNING_ENDPOINT: ${{ secrets.ARTIFACT_SIGNING_ENDPOINT }}
+ ARTIFACT_SIGNING_ACCOUNT: ${{ secrets.ARTIFACT_SIGNING_ACCOUNT }}
+ ARTIFACT_SIGNING_PROFILE: ${{ secrets.ARTIFACT_SIGNING_PROFILE }}
+ run: ./scripts/windows-signing-setup.ps1
+
- name: Build and release Tauri app
+ # Every leg, except Windows when SignPath signs: that lane cannot let
+ # this step publish, because the installers it would attach, and the
+ # updater signatures over them, are the unsigned ones. On Linux the
+ # detect step is skipped and its output is empty, so this is true.
+ if: matrix.platform != 'windows-latest' || steps.signcfg.outputs.signpath != 'true'
uses: tauri-apps/tauri-action@51a9f1156b33df106d827c3a78f8f894946c5faa # v0.5.25
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
+ # Read by SignTool's Artifact Signing plug-in at signing time, and by
+ # nothing else. Empty without the secrets, and then nothing asks for
+ # them: no signCommand is configured (see the winsign step above).
+ AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
+ AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
+ AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
# K1-18 (lu-301/e2e/linux/BERICHT.md, section "K1-18"): measured on a
# real Ubuntu 24.04 box, `tauri build --bundles appimage` on this
# project's Linux config makes linuxdeploy resolve
@@ -556,7 +652,116 @@ jobs:
# for signed artefacts cannot be built by anyone who lacks the key
# (a0030ad2, the exit-1-after-bundling defect of v2.6.7). The overlay
# is merged on top of the checked-in config by `tauri build`.
- args: --config src-tauri/tauri.release.conf.json ${{ matrix.args }}
+ #
+ # The last expression is empty unless Windows signing is configured;
+ # then it is a second --config, the overlay that sets
+ # bundle.windows.signCommand (scripts/windows-signing-setup.ps1).
+ args: --config src-tauri/tauri.release.conf.json ${{ matrix.args }} ${{ steps.winsign.outputs.config_args }}
+
+ # A configured signCommand that signed nothing must not pass for a signed
+ # release. Skipped on the unsigned path, like the setup step.
+ - name: Verify the Windows signatures
+ id: winverify
+ if: matrix.platform == 'windows-latest' && steps.signcfg.outputs.windows == 'true'
+ shell: pwsh
+ timeout-minutes: 10
+ run: ./scripts/windows-signing-verify.ps1 -SignTool "${{ steps.winsign.outputs.signtool }}"
+
+ # ── Windows code signing with SignPath, only with its values ─────────
+ # Builds, signs and verifies; see the header of the action for the
+ # order and for why it takes two signing requests. It publishes nothing.
+ # The publisher check refuses anything but the certificate of the
+ # SignPath Foundation, so a release can never go out under the
+ # self-signed test certificate: that one is for signpath-probe.yml.
+ - name: Build and sign the Windows installers (SignPath)
+ id: signpath
+ if: matrix.platform == 'windows-latest' && steps.signcfg.outputs.signpath == 'true'
+ uses: ./.github/actions/windows-signpath
+ with:
+ api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
+ organization-id: ${{ vars.SIGNPATH_ORGANIZATION_ID }}
+ project-slug: ${{ vars.SIGNPATH_PROJECT_SLUG }}
+ signing-policy-slug: ${{ vars.SIGNPATH_SIGNING_POLICY_SLUG }}
+ expected-publisher: ${{ vars.SIGNPATH_EXPECTED_PUBLISHER || 'SignPath Foundation' }}
+ updater-private-key: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
+ updater-private-key-password: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
+
+ # What tauri-action does for the other lanes, for the files this lane
+ # signed after the build: attach them to the release and point the
+ # Windows entries of latest.json at them. The Linux leg writes its own
+ # entries into the same file with tauri-action, at a time this leg does
+ # not control, so the merge is read back and repeated if the other leg
+ # wrote in between.
+ - name: Attach the signed Windows installers and update latest.json
+ if: matrix.platform == 'windows-latest' && steps.signcfg.outputs.signpath == 'true'
+ shell: bash
+ timeout-minutes: 45
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }}
+ DIST: ${{ steps.signpath.outputs.dist }}
+ run: |
+ set -euo pipefail
+ # On workflow_dispatch the release may not exist yet: the Linux leg
+ # creates it when its own build is through.
+ for attempt in $(seq 1 60); do
+ if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then break; fi
+ if [ "$attempt" -eq 60 ]; then
+ echo "::error::release $TAG does not exist after 30 minutes; the signed installers were not attached"
+ exit 1
+ fi
+ sleep 30
+ done
+ cd "$DIST"
+ gh release upload "$TAG" ./* --repo "$GITHUB_REPOSITORY" --clobber
+ RELEASE_NOTES="$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json body --jq .body)"
+ export RELEASE_NOTES
+ base="https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG"
+ work="$(mktemp -d)"
+ for attempt in 1 2 3 4 5; do
+ rm -f "$work/latest.json"
+ gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern latest.json --dir "$work" 2>/dev/null \
+ || echo "no latest.json on the release yet, starting one"
+ node "$GITHUB_WORKSPACE/scripts/windows-signpath.mjs" merge-latest-json . "$work/latest.json" "$base"
+ cp "$work/latest.json" "$work/wanted.json"
+ gh release upload "$TAG" "$work/latest.json" --repo "$GITHUB_REPOSITORY" --clobber
+ sleep 45
+ rm -f "$work/latest.json"
+ gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern latest.json --dir "$work"
+ if node -e '
+ const [now, wanted] = process.argv.slice(1).map((f) => JSON.parse(require("fs").readFileSync(f, "utf8")).platforms)
+ const kept = Object.keys(wanted).filter((k) => k.startsWith("windows-")).every((k) => now[k] && now[k].signature === wanted[k].signature)
+ process.exit(kept ? 0 : 1)
+ ' "$work/latest.json" "$work/wanted.json"; then
+ echo "latest.json on $TAG names the signed Windows installers"
+ exit 0
+ fi
+ echo "latest.json was rewritten by another job, merging again (attempt $attempt)"
+ done
+ echo "::error::latest.json on $TAG does not keep the Windows entries of the signed installers"
+ exit 1
+
+ - name: Say on the run page whether this Windows build is signed
+ if: matrix.platform == 'windows-latest'
+ shell: bash
+ env:
+ AZURE: ${{ steps.signcfg.outputs.windows }}
+ AZURE_PUBLISHER: ${{ steps.winverify.outputs.publisher }}
+ SIGNPATH: ${{ steps.signcfg.outputs.signpath }}
+ SIGNPATH_PUBLISHER: ${{ steps.signpath.outputs.publisher }}
+ SIGNPATH_APP_REQUEST: ${{ steps.signpath.outputs.app-signing-request }}
+ SIGNPATH_INSTALLERS_REQUEST: ${{ steps.signpath.outputs.installers-signing-request }}
+ run: |
+ if [ "$AZURE" = "true" ]; then
+ echo "Windows installers: signed with Azure Artifact Signing, publisher \`$AZURE_PUBLISHER\`." >> "$GITHUB_STEP_SUMMARY"
+ elif [ "$SIGNPATH" = "true" ]; then
+ {
+ echo "Windows installers: signed with SignPath, publisher \`$SIGNPATH_PUBLISHER\`."
+ echo "Signing requests: [app binary]($SIGNPATH_APP_REQUEST), [installers]($SIGNPATH_INSTALLERS_REQUEST)."
+ } >> "$GITHUB_STEP_SUMMARY"
+ else
+ echo "Windows installers: unsigned (no signing lane is configured)." >> "$GITHUB_STEP_SUMMARY"
+ fi
# K1-18 (lu-301/e2e/linux/BERICHT.md): the LD_LIBRARY_PATH fix above
# only proves linuxdeploy did not hard-fail; K1-18 itself measured that
@@ -641,11 +846,148 @@ jobs:
[ "$missing" -eq 0 ] || exit 1
echo "OK: every staged sidecar companion is present inside the built .deb ($extracted_llama_dir)"
+ # ── macOS, Developer ID signed and notarized, or not at all ──────────────
+ #
+ # The lane c1644d9a removed, back under the one condition that commit named:
+ # Apple Developer ID credentials. Without them `signing-config` answers
+ # macos=false, this job is skipped (a skipped job is not a failed run), and
+ # the release has no macOS assets, exactly as today. There is deliberately no
+ # unsigned or ad hoc fallback: that is what was shipped once and pulled.
+ #
+ # Apple Silicon only. Local inference on a Mac is MLX, which has no Intel
+ # build, so there is no x86_64-apple-darwin lane.
+ #
+ # Signing and the notarization of the .app happen inside `tauri build`
+ # (tauri-cli 2.10.1): APPLE_CERTIFICATE and its password make the bundler
+ # import the .p12 into a keychain of its own, sign the sidecar and the app
+ # with the Hardened Runtime and src-tauri/Entitlements.plist, submit the app
+ # with notarytool and staple it. scripts/macos-release-signing.sh does the
+ # rest: it verifies every Mach-O file in the bundle, notarizes and staples
+ # the disk image, and asks spctl for Gatekeeper's verdict on both.
+ #
+ # ci.yml's build gate has no macOS lane. The checks of `gate` therefore
+ # cover the code this job builds, but not its bundling on macOS; the first
+ # proof that it bundles is this job's own run.
+ build-macos:
+ needs: [gate, signing-config]
+ if: needs.signing-config.outputs.macos == 'true'
+ runs-on: macos-14
+ timeout-minutes: 90
+ env:
+ SIDECAR_TRIPLE: aarch64-apple-darwin
+ RELEASE_TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }}
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
+ with:
+ ref: ${{ github.event.release.tag_name || github.event.inputs.tag }}
+
+ - name: Setup Node.js
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
+ with:
+ node-version: 22
+
+ - name: Install Rust stable
+ uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
+
+ - name: Rust cache
+ uses: swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
+ with:
+ workspaces: './src-tauri -> target'
+
+ - name: Sidecar build cache
+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: .llama-build
+ key: llama-${{ hashFiles('scripts/build-llama.sh') }}-${{ env.SIDECAR_TRIPLE }}-v1
+
+ # One static binary with Metal embedded (scripts/build-llama.sh), so
+ # there are no companion libraries to sign next to it.
+ - name: Build llama-server sidecar
+ env:
+ BUILD_JOBS: 2
+ run: bash scripts/build-llama.sh "$SIDECAR_TRIPLE"
+
+ - name: Assert sidecar exists
+ run: |
+ test -x "src-tauri/bin/lu-llama-server-$SIDECAR_TRIPLE"
+ ls -la src-tauri/bin/
+
+ - name: Install npm dependencies
+ run: npm ci
+
+ # Exactly one set of notarization credentials reaches the build, through
+ # $GITHUB_ENV. Why not through the `env:` of the build step: see the
+ # header of the script.
+ - name: Hand the notarization credentials to the build
+ env:
+ NOTARY_MODE: ${{ needs.signing-config.outputs.macos_notary }}
+ NOTARY_API_KEY: ${{ secrets.APPLE_API_KEY }}
+ NOTARY_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
+ NOTARY_API_KEY_P8: ${{ secrets.APPLE_API_KEY_P8 }}
+ NOTARY_APPLE_ID: ${{ secrets.APPLE_ID }}
+ NOTARY_APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
+ EXPECTED_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
+ run: bash scripts/macos-release-signing.sh prepare
+
+ - name: Build, sign, notarize and release the macOS app
+ uses: tauri-apps/tauri-action@51a9f1156b33df106d827c3a78f8f894946c5faa # v0.5.25
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
+ APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
+ APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
+ # Overrides bundle.macOS.signingIdentity ("-", the ad hoc identity
+ # local builds use). The bundler takes the identity from the imported
+ # certificate and only requires that its name contains this string,
+ # so the default also refuses a .p12 that holds the wrong kind of
+ # certificate, for example an "Apple Development" one.
+ APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY || 'Developer ID Application' }}
+ with:
+ tagName: ${{ github.event.release.tag_name || github.event.inputs.tag || 'v1.3.0' }}
+ releaseName: 'LU ${{ github.event.release.tag_name || github.event.inputs.tag }}'
+ releaseDraft: false
+ # Same promise as the Windows and Linux lane: a build is not a
+ # decision. enforce-prerelease below holds it for every trigger.
+ prerelease: true
+ args: --config src-tauri/tauri.release.conf.json
+
+ - name: Verify signatures, notarize and staple the disk image, ask Gatekeeper
+ id: finish
+ timeout-minutes: 30
+ env:
+ EXPECTED_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
+ run: bash scripts/macos-release-signing.sh finish src-tauri/target
+
+ # The build step uploaded the disk image before it had a ticket of its
+ # own. Replace that one asset with the stapled file. latest.json does not
+ # name the disk image (the updater takes the .app.tar.gz, packed from the
+ # already stapled app), so no updater signature changes.
+ - name: Replace the uploaded disk image with the stapled one
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ DMG: ${{ steps.finish.outputs.dmg }}
+ run: |
+ set -euo pipefail
+ names="$(gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name | select(endswith(".dmg"))')"
+ count="$(printf '%s\n' "$names" | sed '/^$/d' | wc -l | tr -d ' ')"
+ if [ "$count" -ne 1 ]; then
+ echo "::error::expected exactly one .dmg asset on $RELEASE_TAG, found $count: $names"
+ exit 1
+ fi
+ staged="$RUNNER_TEMP/$names"
+ cp "$DMG" "$staged"
+ gh release upload "$RELEASE_TAG" "$staged" --repo "$GITHUB_REPOSITORY" --clobber
+ echo "macOS: \`$names\` is Developer ID signed, notarized and stapled." >> "$GITHUB_STEP_SUMMARY"
+
# The promise above, made real for every trigger. Runs after the binaries are
# attached, so a release published as a full release is put back before
# anyone is offered it, and never touches the release that is already Latest.
+ # It waits for the macOS job too, which may be skipped; `always()` covers
+ # that case as it covers a failed lane.
enforce-prerelease:
- needs: build-tauri
+ needs: [build-tauri, build-macos]
if: always()
runs-on: ubuntu-22.04
steps:
diff --git a/.github/workflows/signpath-probe.yml b/.github/workflows/signpath-probe.yml
new file mode 100644
index 00000000..65f23db3
--- /dev/null
+++ b/.github/workflows/signpath-probe.yml
@@ -0,0 +1,163 @@
+name: SignPath signing probe (Windows)
+
+# Runs the SignPath signing lane of release.yml once, by hand, so that the
+# setup can be tried and shown to SignPath before a release depends on it.
+#
+# It builds the commit it is started on, sends the same two signing requests
+# a release sends (.github/actions/windows-signpath), verifies the result and
+# keeps the signed installers as a workflow artifact for 7 days.
+#
+# What it never does: it creates no release, attaches nothing to one, and
+# does not read or write latest.json. The updater signatures it writes are
+# made with a key generated in the run and thrown away with it, so the release
+# updater key is not used here and no installed app would accept these files
+# as an update.
+#
+# The default signing policy is test-signing, whose certificate is
+# self-signed. Windows does not trust it, and the probe accepts exactly that.
+# To try the production certificate, start it with the release policy and
+# switch "allow-test-certificate" off.
+
+on:
+ workflow_dispatch:
+ inputs:
+ signing-policy-slug:
+ description: 'SignPath signing policy slug'
+ required: true
+ default: 'test-signing'
+ allow-test-certificate:
+ description: 'Accept a self-signed certificate that Windows does not trust'
+ type: boolean
+ default: true
+ expected-publisher:
+ description: 'Text the certificate subject must contain (empty: not checked)'
+ required: false
+ default: ''
+
+permissions:
+ contents: read
+ actions: read
+
+env:
+ # Same pin as release.yml and sidecar-windows.yml; bump the three together.
+ VULKAN_SDK_VERSION: '1.4.313.2'
+
+jobs:
+ probe:
+ # SignPath accepts builds from GitHub-hosted runners only.
+ runs-on: windows-latest
+ # Long enough for a policy with manual approval: two requests, each may
+ # wait two hours for a person.
+ timeout-minutes: 360
+ env:
+ SIDECAR_TRIPLE: x86_64-pc-windows-msvc
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
+
+ - name: Which SignPath values are present
+ id: signcfg
+ shell: bash
+ env:
+ SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }}
+ SIGNPATH_ORGANIZATION_ID: ${{ vars.SIGNPATH_ORGANIZATION_ID }}
+ SIGNPATH_PROJECT_SLUG: ${{ vars.SIGNPATH_PROJECT_SLUG }}
+ SIGNPATH_SIGNING_POLICY_SLUG: ${{ inputs.signing-policy-slug }}
+ run: bash scripts/signing-config.sh windows
+
+ - name: Stop when the SignPath values are incomplete
+ if: steps.signcfg.outputs.signpath != 'true'
+ shell: bash
+ run: |
+ echo "::error::The probe needs the secret SIGNPATH_API_TOKEN and the repository variables SIGNPATH_ORGANIZATION_ID and SIGNPATH_PROJECT_SLUG."
+ exit 1
+
+ - name: Setup Node.js
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
+ with:
+ node-version: 22
+
+ - name: Install Rust stable
+ uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
+
+ - name: Rust cache
+ uses: swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
+ with:
+ workspaces: './src-tauri -> target'
+
+ # The bundled llama.cpp server has to exist before the app builds
+ # (tauri-build fails on a missing externalBin). Same steps and the same
+ # cache key as the Windows leg of release.yml.
+ - name: Sidecar build cache
+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: D:/lb
+ key: llama-${{ hashFiles('scripts/build-llama.sh') }}-${{ env.SIDECAR_TRIPLE }}-v1
+
+ - name: Install Vulkan SDK
+ shell: pwsh
+ run: |
+ curl.exe -fL --retry 3 -o "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" `
+ "https://sdk.lunarg.com/sdk/download/${env:VULKAN_SDK_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_SDK_VERSION}.exe"
+ if ($LASTEXITCODE -ne 0) { throw "Vulkan SDK download failed" }
+ & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
+ Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_SDK_VERSION}"
+
+ - name: Build llama-server sidecar
+ shell: bash
+ env:
+ BUILD_JOBS: 2
+ LLAMA_BUILD_CACHE: 'D:/lb'
+ run: bash scripts/build-llama.sh "$SIDECAR_TRIPLE"
+
+ - name: Assert sidecar exists
+ shell: bash
+ run: test -f "src-tauri/bin/lu-llama-server-$SIDECAR_TRIPLE.exe"
+
+ - name: Install npm dependencies
+ run: npm ci
+
+ # Not the release key: one that exists for this run only.
+ - name: Generate a throwaway updater key
+ id: probe-key
+ shell: bash
+ run: |
+ set -euo pipefail
+ npx tauri signer generate --ci -w "$RUNNER_TEMP/probe-updater.key" > /dev/null
+ key="$(cat "$RUNNER_TEMP/probe-updater.key")"
+ echo "::add-mask::$key"
+ echo "key=$key" >> "$GITHUB_OUTPUT"
+
+ - name: Build and sign the Windows installers (SignPath)
+ id: signpath
+ uses: ./.github/actions/windows-signpath
+ with:
+ api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
+ organization-id: ${{ vars.SIGNPATH_ORGANIZATION_ID }}
+ project-slug: ${{ vars.SIGNPATH_PROJECT_SLUG }}
+ signing-policy-slug: ${{ inputs.signing-policy-slug }}
+ expected-publisher: ${{ inputs.expected-publisher }}
+ allow-test-certificate: ${{ inputs.allow-test-certificate }}
+ updater-private-key: ${{ steps.probe-key.outputs.key }}
+
+ - name: Keep the signed installers as a workflow artifact
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: windows-signpath-probe
+ path: ${{ steps.signpath.outputs.dist }}
+ if-no-files-found: error
+ retention-days: 7
+
+ - name: Say on the run page what was signed
+ shell: bash
+ env:
+ POLICY: ${{ inputs.signing-policy-slug }}
+ PUBLISHER: ${{ steps.signpath.outputs.publisher }}
+ APP_REQUEST: ${{ steps.signpath.outputs.app-signing-request }}
+ INSTALLERS_REQUEST: ${{ steps.signpath.outputs.installers-signing-request }}
+ run: |
+ {
+ echo "SignPath probe with signing policy \`$POLICY\`: both requests completed, publisher \`$PUBLISHER\`."
+ echo "Signing requests: [app binary]($APP_REQUEST), [installers]($INSTALLERS_REQUEST)."
+ echo "Nothing was published. The signed installers are in the workflow artifact \`windows-signpath-probe\`."
+ } >> "$GITHUB_STEP_SUMMARY"
diff --git a/.gitignore b/.gitignore
index 26e193e1..eb52f84e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,10 @@ pnpm-lock.yaml
# Rust build artifacts
src-tauri/target/
+# Written by scripts/windows-signing-setup.ps1 during a signed release build:
+# the Tauri overlay that names the sign command. Never part of the tree.
+src-tauri/tauri.signing.conf.json
+
# Environment
.env
diff --git a/.signpath/artifact-configurations/windows-app.xml b/.signpath/artifact-configurations/windows-app.xml
new file mode 100644
index 00000000..c75045a6
--- /dev/null
+++ b/.signpath/artifact-configurations/windows-app.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SignPath artifact configuration, slug "windows-app".
+
+ First signing request of a Windows release: the app binary, before it is
+ packed into the installers. The GitHub artifact is a ZIP archive, so the
+ root element is a zip-file. It holds the same build twice, once marked for
+ the NSIS installer and once for the MSI (scripts/windows-signpath.mjs
+ explains why). Nothing else is in the archive and nothing else is signed:
+ the bundled llama.cpp server and its libraries are built from upstream
+ source and stay unsigned.
+
+ The metadata restrictions are the ones the SignPath Foundation asks for:
+ the product name is fixed, and the product version must equal the version
+ the workflow passes as a parameter.
+-->
+<artifact-configuration xmlns="http://signpath.io/artifact-configuration/v1">
+ <parameters>
+ <parameter name="version" required="true" />
+ </parameters>
+ <zip-file>
+ <directory path="nsis">
+ <pe-file path="locally-uncensored.exe" product-name="Locally Uncensored" product-version="${version}">
+ <authenticode-sign description="LU" description-url="https://github.com/PurpleDoubleD/locally-uncensored" />
+ </pe-file>
+ </directory>
+ <directory path="msi">
+ <pe-file path="locally-uncensored.exe" product-name="Locally Uncensored" product-version="${version}">
+ <authenticode-sign description="LU" description-url="https://github.com/PurpleDoubleD/locally-uncensored" />
+ </pe-file>
+ </directory>
+ </zip-file>
+</artifact-configuration>
diff --git a/.signpath/artifact-configurations/windows-installers.xml b/.signpath/artifact-configurations/windows-installers.xml
new file mode 100644
index 00000000..2b35b21e
--- /dev/null
+++ b/.signpath/artifact-configurations/windows-installers.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SignPath artifact configuration, slug "windows-installers".
+
+ Second signing request of a Windows release: the two installers, built
+ around the app binary that the first request signed. Only the installer
+ files themselves are signed here. SignPath has no composite type for NSIS,
+ so the NSIS installer is a plain PE file, and the MSI is signed as a whole
+ without touching its contents, which already carry their signature or are
+ upstream files that stay unsigned.
+
+ The NSIS installer carries the product name and version in its version
+ resource (Tauri's installer template writes both), so the same restrictions
+ apply as for the app binary.
+-->
+<artifact-configuration xmlns="http://signpath.io/artifact-configuration/v1">
+ <parameters>
+ <parameter name="version" required="true" />
+ </parameters>
+ <zip-file>
+ <pe-file path="Locally Uncensored_${version}_x64-setup.exe" product-name="Locally Uncensored" product-version="${version}">
+ <authenticode-sign description="LU Setup" description-url="https://github.com/PurpleDoubleD/locally-uncensored" />
+ </pe-file>
+ <msi-file path="Locally Uncensored_${version}_x64_en-US.msi">
+ <authenticode-sign description="LU Setup" description-url="https://github.com/PurpleDoubleD/locally-uncensored" />
+ </msi-file>
+ </zip-file>
+</artifact-configuration>
diff --git a/scripts/macos-release-signing.sh b/scripts/macos-release-signing.sh
new file mode 100755
index 00000000..a9c7fa15
--- /dev/null
+++ b/scripts/macos-release-signing.sh
@@ -0,0 +1,176 @@
+#!/usr/bin/env bash
+#
+# macos-release-signing.sh: the two halves of the macOS release lane that
+# `tauri build` does not do by itself. Runs only in release.yml's build-macos
+# job, which exists only when scripts/signing-config.sh found the Apple secrets.
+#
+# prepare Hands exactly ONE set of notarization credentials to the build.
+# finish Proves what the build signed, notarizes and staples the disk
+# image, and asks Gatekeeper for its verdict.
+#
+# What `tauri build` does in between, read at tauri-cli 2.10.1 (the version in
+# package-lock.json): with APPLE_CERTIFICATE and APPLE_CERTIFICATE_PASSWORD set
+# it imports the .p12 into a keychain of its own and deletes it afterwards. It
+# signs the frameworks, every externalBin (lu-llama-server) and the main binary
+# with the Hardened Runtime and bundle.macOS.entitlements, then the .app. With
+# notarization credentials in the environment it submits the .app through
+# notarytool, waits, and staples it. It signs the .dmg but neither notarizes
+# nor staples it. The updater archive is packed from the stapled .app.
+#
+# Nothing here touches a keychain.
+set -euo pipefail
+
+die() { echo "::error::$*" >&2; exit 1; }
+
+# ── prepare ────────────────────────────────────────────────────────────────
+#
+# tauri-bundler reads APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID first and the API
+# key variables second, and it tests for "is set", not "is non-empty". A
+# workflow step that maps every secret into its env would hand it empty Apple
+# ID variables next to a real API key, and it would try to notarize with the
+# empty ones. So the build step gets none of them from the workflow file: this
+# function writes the one complete set to $GITHUB_ENV and leaves the other
+# names unset.
+prepare() {
+ : "${GITHUB_ENV:?prepare runs inside GitHub Actions}"
+ : "${RUNNER_TEMP:?prepare runs inside GitHub Actions}"
+ case "${NOTARY_MODE:-}" in
+ api)
+ [ -n "${NOTARY_API_KEY:-}" ] && [ -n "${NOTARY_API_ISSUER:-}" ] && [ -n "${NOTARY_API_KEY_P8:-}" ] \
+ || die "NOTARY_MODE=api but the API key secrets are incomplete"
+ umask 077
+ local dir="$RUNNER_TEMP/private_keys"
+ local key="$dir/AuthKey_${NOTARY_API_KEY}.p8"
+ mkdir -p "$dir"
+ # The secret may hold the .p8 file as it was downloaded, or its base64.
+ if printf '%s' "$NOTARY_API_KEY_P8" | grep -q 'BEGIN PRIVATE KEY'; then
+ printf '%s\n' "$NOTARY_API_KEY_P8" > "$key"
+ else
+ printf '%s' "$NOTARY_API_KEY_P8" | base64 --decode > "$key"
+ fi
+ grep -q 'BEGIN PRIVATE KEY' "$key" || die "APPLE_API_KEY_P8 is neither the .p8 file nor its base64"
+ {
+ echo "APPLE_API_KEY=$NOTARY_API_KEY"
+ echo "APPLE_API_ISSUER=$NOTARY_API_ISSUER"
+ echo "APPLE_API_KEY_PATH=$key"
+ } >> "$GITHUB_ENV"
+ echo "notarization: App Store Connect API key"
+ ;;
+ appleid)
+ [ -n "${NOTARY_APPLE_ID:-}" ] && [ -n "${NOTARY_APPLE_PASSWORD:-}" ] && [ -n "${EXPECTED_TEAM_ID:-}" ] \
+ || die "NOTARY_MODE=appleid but the Apple ID secrets are incomplete"
+ {
+ echo "APPLE_ID=$NOTARY_APPLE_ID"
+ echo "APPLE_PASSWORD=$NOTARY_APPLE_PASSWORD"
+ echo "APPLE_TEAM_ID=$EXPECTED_TEAM_ID"
+ } >> "$GITHUB_ENV"
+ echo "notarization: Apple ID with an app-specific password"
+ ;;
+ *) die "NOTARY_MODE must be api or appleid, got '${NOTARY_MODE:-}'" ;;
+ esac
+}
+
+# The notarytool arguments for the set `prepare` exported.
+notary_auth() {
+ if [ -n "${APPLE_API_KEY_PATH:-}" ]; then
+ printf '%s\n' --key "$APPLE_API_KEY_PATH" --key-id "$APPLE_API_KEY" --issuer "$APPLE_API_ISSUER"
+ else
+ printf '%s\n' --apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" --team-id "$APPLE_TEAM_ID"
+ fi
+}
+
+# One signed Mach-O file: Developer ID, our team, a secure timestamp, and the
+# Hardened Runtime if it is an executable. Notarization demands all four, and a
+# file that misses one is named here instead of in Apple's log.
+check_macho() {
+ local path="$1" kind info
+ kind="$(file -b "$path")"
+ case "$kind" in *Mach-O*) ;; *) return 0 ;; esac
+ info="$(codesign -dvv "$path" 2>&1)" || die "not signed: $path"
+ echo "$info" | grep -q '^Authority=Developer ID Application' \
+ || die "not signed with a Developer ID Application certificate: $path"
+ if [ -n "${EXPECTED_TEAM_ID:-}" ]; then
+ echo "$info" | grep -q "^TeamIdentifier=${EXPECTED_TEAM_ID}\$" \
+ || die "signed by a different team than APPLE_TEAM_ID: $path"
+ fi
+ echo "$info" | grep -q '^Timestamp=' || die "no secure timestamp: $path"
+ case "$kind" in
+ *executable*)
+ echo "$info" | grep -Eq '^CodeDirectory .*flags=0x[0-9a-f]+\(.*runtime.*\)' \
+ || die "executable without the Hardened Runtime: $path"
+ ;;
+ esac
+ echo "ok $path"
+}
+
+# ── finish ─────────────────────────────────────────────────────────────────
+finish() {
+ local bundle_root="${1:-src-tauri/target}"
+ local app dmg
+ app="$(find "$bundle_root" -type d -path '*/bundle/macos/*.app' -print -quit)"
+ dmg="$(find "$bundle_root" -type f -path '*/bundle/dmg/*.dmg' -print -quit)"
+ [ -n "$app" ] || die "no .app under $bundle_root/**/bundle/macos"
+ [ -n "$dmg" ] || die "no .dmg under $bundle_root/**/bundle/dmg"
+ echo "app: $app"
+ echo "dmg: $dmg"
+
+ echo "== 1. the seal of the app bundle"
+ codesign --verify --deep --strict --verbose=2 "$app"
+
+ echo "== 2. every Mach-O file inside it"
+ local file_path
+ while IFS= read -r -d '' file_path; do
+ check_macho "$file_path"
+ done < <(find "$app" -type f -print0)
+
+ echo "== 3. entitlements of the main binary"
+ local entitlements
+ entitlements="$(codesign -d --entitlements - --xml "$app" 2>/dev/null || true)"
+ echo "$entitlements"
+ if echo "$entitlements" | grep -q 'get-task-allow'; then
+ die "the app carries com.apple.security.get-task-allow, notarization rejects that"
+ fi
+
+ echo "== 4. the notarization ticket tauri build stapled to the app"
+ xcrun stapler validate "$app"
+ local verdict
+ verdict="$(spctl --assess --type execute -vv "$app" 2>&1)" || { echo "$verdict"; die "Gatekeeper rejects the app"; }
+ echo "$verdict"
+ echo "$verdict" | grep -q 'source=Notarized Developer ID' \
+ || die "Gatekeeper accepts the app, but not as Notarized Developer ID"
+
+ echo "== 5. notarize and staple the disk image"
+ codesign --verify --verbose=2 "$dmg"
+ local auth=() line
+ while IFS= read -r line; do auth+=("$line"); done < <(notary_auth)
+ local result="${RUNNER_TEMP:-/tmp}/notary-dmg.json"
+ # notarytool exits 0 for a submission Apple answered with "Invalid", so the
+ # status is read from its JSON, not from the exit code.
+ xcrun notarytool submit "$dmg" "${auth[@]}" --wait --output-format json > "$result" || true
+ cat "$result"
+ local status id
+ status="$(plutil -extract status raw -o - "$result" 2>/dev/null || true)"
+ id="$(plutil -extract id raw -o - "$result" 2>/dev/null || true)"
+ if [ "$status" != "Accepted" ]; then
+ [ -n "$id" ] && xcrun notarytool log "$id" "${auth[@]}" || true
+ die "Apple did not accept the disk image (status: ${status:-none})"
+ fi
+ xcrun stapler staple -v "$dmg"
+ xcrun stapler validate "$dmg"
+ verdict="$(spctl --assess --type open --context context:primary-signature -vv "$dmg" 2>&1)" \
+ || { echo "$verdict"; die "Gatekeeper rejects the disk image"; }
+ echo "$verdict"
+ echo "$verdict" | grep -q 'source=Notarized Developer ID' \
+ || die "Gatekeeper accepts the disk image, but not as Notarized Developer ID"
+
+ if [ -n "${GITHUB_OUTPUT:-}" ]; then
+ echo "dmg=$dmg" >> "$GITHUB_OUTPUT"
+ fi
+ echo "OK: app and disk image are signed, notarized and stapled, and Gatekeeper accepts both"
+}
+
+case "${1:-}" in
+ prepare) prepare ;;
+ finish) shift; finish "$@" ;;
+ *) echo "usage: $0 prepare | finish [bundle-root]" >&2; exit 2 ;;
+esac
diff --git a/scripts/signing-config.sh b/scripts/signing-config.sh
new file mode 100755
index 00000000..6166940e
--- /dev/null
+++ b/scripts/signing-config.sh
@@ -0,0 +1,125 @@
+#!/usr/bin/env bash
+#
+# signing-config.sh: which code signing lanes of release.yml can run?
+#
+# release.yml builds unsigned installers for Windows and Linux and no macOS
+# build at all. Both facts change only when the matching repository secrets
+# exist, and this script is the one place that decides whether they do. It
+# reads the secrets from its environment, never prints a value, and writes
+# four answers to $GITHUB_OUTPUT:
+#
+# macos=true|false the notarized macOS lane (job build-macos) runs
+# macos_notary=api|appleid which notarization credentials it uses
+# windows=true|false the Windows lane signs with Azure Artifact Signing
+# signpath=true|false the Windows lane signs with SignPath
+#
+# Called with `macos` or `windows` it answers for that lane alone, which is
+# how the two jobs of release.yml use it: each hands over only its own secrets.
+#
+# Windows has two signing routes and a release can take only one of them:
+# Azure signs inside `tauri build`, SignPath signs uploaded artifacts after
+# it. When both sets are complete the script stops the run with an error
+# instead of picking one.
+#
+# A lane is on only when EVERY value it needs is present. A half-filled set is
+# reported as a warning on the run and treated as "off": the build then stays
+# exactly what it is today. That keeps a fork, and this repository before the
+# accounts exist, on the unsigned path with a green run.
+set -euo pipefail
+
+# True when every named variable is non-empty.
+have_all() {
+ local name
+ for name in "$@"; do
+ [ -n "${!name:-}" ] || return 1
+ done
+}
+
+# True when at least one named variable is non-empty.
+have_any() {
+ local name
+ for name in "$@"; do
+ if [ -n "${!name:-}" ]; then return 0; fi
+ done
+ return 1
+}
+
+# The names of the given variables that are empty, space separated.
+missing_of() {
+ local name out=""
+ for name in "$@"; do
+ [ -n "${!name:-}" ] || out="$out $name"
+ done
+ printf '%s' "${out# }"
+}
+
+scope="${1:-all}"
+case "$scope" in all | macos | windows) ;; *) echo "usage: $0 [macos|windows]" >&2; exit 2 ;; esac
+
+MAC_CERT=(APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD)
+MAC_NOTARY_API=(APPLE_API_KEY APPLE_API_ISSUER APPLE_API_KEY_P8)
+MAC_NOTARY_APPLEID=(APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID)
+WINDOWS=(AZURE_TENANT_ID AZURE_CLIENT_ID AZURE_CLIENT_SECRET
+ ARTIFACT_SIGNING_ENDPOINT ARTIFACT_SIGNING_ACCOUNT ARTIFACT_SIGNING_PROFILE)
+# The API token is a secret. The other three are identifiers, not secrets, and
+# are read from repository variables.
+SIGNPATH=(SIGNPATH_API_TOKEN SIGNPATH_ORGANIZATION_ID SIGNPATH_PROJECT_SLUG
+ SIGNPATH_SIGNING_POLICY_SLUG)
+
+macos=false
+macos_notary=""
+if [ "$scope" = windows ]; then
+ :
+elif have_all "${MAC_CERT[@]}"; then
+ if have_all "${MAC_NOTARY_API[@]}"; then
+ macos=true
+ macos_notary=api
+ elif have_all "${MAC_NOTARY_APPLEID[@]}"; then
+ macos=true
+ macos_notary=appleid
+ else
+ echo "::warning title=macOS signing is off::The Developer ID certificate is set, but neither notarization set is complete. API key set is missing: $(missing_of "${MAC_NOTARY_API[@]}"). Apple ID set is missing: $(missing_of "${MAC_NOTARY_APPLEID[@]}"). No macOS build is made."
+ fi
+elif have_any "${MAC_CERT[@]}" "${MAC_NOTARY_API[@]}" APPLE_ID APPLE_PASSWORD; then
+ echo "::warning title=macOS signing is off::Some Apple secrets are set, but the certificate pair is incomplete. Missing: $(missing_of "${MAC_CERT[@]}"). No macOS build is made."
+fi
+
+windows=false
+if [ "$scope" = macos ]; then
+ :
+elif have_all "${WINDOWS[@]}"; then
+ windows=true
+elif have_any "${WINDOWS[@]}"; then
+ echo "::warning title=Azure Artifact Signing is off::Some Azure Artifact Signing secrets are set, but not all six. Missing: $(missing_of "${WINDOWS[@]}"). Azure does not sign this build."
+fi
+
+signpath=false
+if [ "$scope" = macos ]; then
+ :
+elif have_all "${SIGNPATH[@]}"; then
+ signpath=true
+elif have_any "${SIGNPATH[@]}"; then
+ echo "::warning title=SignPath signing is off::Some SignPath values are set, but not all four. Missing: $(missing_of "${SIGNPATH[@]}"). SignPath does not sign this build."
+fi
+
+if [ "$windows" = true ] && [ "$signpath" = true ]; then
+ echo "::error title=Two Windows signing lanes are configured::Both the Azure Artifact Signing secrets and the SignPath values are complete. A release is signed by exactly one of them. Remove the secrets or variables of the lane that should not sign and run again."
+ exit 1
+fi
+
+out="${GITHUB_OUTPUT:-/dev/stdout}"
+if [ "$scope" != windows ]; then
+ {
+ echo "macos=$macos"
+ echo "macos_notary=$macos_notary"
+ } >> "$out"
+ echo "macOS lane: $macos${macos_notary:+ (notarization via $macos_notary)}"
+fi
+if [ "$scope" != macos ]; then
+ {
+ echo "windows=$windows"
+ echo "signpath=$signpath"
+ } >> "$out"
+ echo "Windows signing with Azure Artifact Signing: $windows"
+ echo "Windows signing with SignPath: $signpath"
+fi
diff --git a/scripts/windows-signing-setup.ps1 b/scripts/windows-signing-setup.ps1
new file mode 100644
index 00000000..512bcc92
--- /dev/null
+++ b/scripts/windows-signing-setup.ps1
@@ -0,0 +1,128 @@
+# windows-signing-setup.ps1: point `tauri build` at Azure Artifact Signing.
+#
+# Runs in release.yml's Windows lane, and only when scripts/signing-config.sh
+# found all six Azure secrets. Without them this script is never called and the
+# installers are built unsigned, as before.
+#
+# What it sets up is Microsoft's own documented route, with no third party
+# tool in between (learn.microsoft.com/azure/artifact-signing/
+# how-to-signing-integrations, read 2026-10-08): SignTool from the Windows SDK
+# loads the Artifact Signing dlib, and the dlib asks the service to sign. The
+# certificate never leaves Azure, so there is no .pfx and nothing to import.
+#
+# 1. Fetch the dlib package from nuget.org, pinned by version and sha256.
+# 2. Find a SignTool the dlib supports.
+# 3. Write metadata.json (endpoint, account, certificate profile).
+# 4. Write a Tauri config overlay that sets bundle.windows.signCommand, and
+# hand its path to the build step as an extra --config argument.
+#
+# With a signCommand in place the bundler signs, read at tauri-cli 2.10.1: the
+# main binary, every externalBin (lu-llama-server.exe), every binary among the
+# bundle resources that is not signed yet (the ggml and llama DLLs), the NSIS
+# plugins and uninstaller, the NSIS installer, and the MSI. The updater
+# signature (.sig) is taken from the signed installer.
+#
+# Authentication happens inside SignTool, at signing time, through the
+# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET variables of the
+# build step. This script does not read them.
+
+$ErrorActionPreference = 'Stop'
+
+function Require-Env([string]$Name) {
+ $value = [Environment]::GetEnvironmentVariable($Name)
+ if ([string]::IsNullOrWhiteSpace($value)) { throw "$Name is not set" }
+ return $value
+}
+
+$endpoint = Require-Env 'ARTIFACT_SIGNING_ENDPOINT'
+$account = Require-Env 'ARTIFACT_SIGNING_ACCOUNT'
+$certificateProfile = Require-Env 'ARTIFACT_SIGNING_PROFILE'
+$clientVersion = Require-Env 'ARTIFACT_SIGNING_CLIENT_VERSION'
+$clientSha256 = Require-Env 'ARTIFACT_SIGNING_CLIENT_SHA256'
+$runnerTemp = Require-Env 'RUNNER_TEMP'
+$workspace = Require-Env 'GITHUB_WORKSPACE'
+
+if ($endpoint -notmatch '^https://[a-z0-9]+\.codesigning\.azure\.net/?$') {
+ throw "ARTIFACT_SIGNING_ENDPOINT must be the region endpoint of the account, for example https://weu.codesigning.azure.net"
+}
+
+# ── 1. The dlib ────────────────────────────────────────────────────────────
+$toolsDir = Join-Path $runnerTemp 'artifact-signing'
+New-Item -ItemType Directory -Force -Path $toolsDir | Out-Null
+$package = Join-Path $toolsDir 'client.zip'
+$packageUrl = "https://api.nuget.org/v3-flatcontainer/microsoft.artifactsigning.client/$clientVersion/microsoft.artifactsigning.client.$clientVersion.nupkg"
+curl.exe -fsSL --retry 3 --max-time 180 -o $package $packageUrl
+if ($LASTEXITCODE -ne 0) { throw "download of the Artifact Signing client $clientVersion failed" }
+$actual = (Get-FileHash -Path $package -Algorithm SHA256).Hash.ToLower()
+if ($actual -ne $clientSha256.ToLower()) {
+ throw "the Artifact Signing client did not match the pinned sha256 (expected $clientSha256, got $actual)"
+}
+$clientDir = Join-Path $toolsDir 'client'
+Expand-Archive -Path $package -DestinationPath $clientDir -Force
+$dlib = Join-Path $clientDir 'bin\x64\Azure.CodeSigning.Dlib.dll'
+if (-not (Test-Path $dlib)) { throw "the client package has no bin\x64\Azure.CodeSigning.Dlib.dll" }
+
+# ── 2. SignTool ────────────────────────────────────────────────────────────
+# The dlib needs the SignTool of Windows SDK 10.0.22621 or newer and does not
+# work with the 20348 SDK. The runner image ships several SDKs side by side;
+# take the newest one that qualifies.
+$kitsBin = Join-Path ${env:ProgramFiles(x86)} 'Windows Kits\10\bin'
+$signtool = Get-ChildItem -Path $kitsBin -Directory -ErrorAction SilentlyContinue |
+ Where-Object { $_.Name -match '^10\.0\.\d+\.\d+$' } |
+ ForEach-Object { [pscustomobject]@{ Version = [version]$_.Name; Path = Join-Path $_.FullName 'x64\signtool.exe' } } |
+ Where-Object { $_.Version.Build -ge 22621 -and (Test-Path $_.Path) } |
+ Sort-Object Version -Descending |
+ Select-Object -First 1
+if (-not $signtool) { throw "no SignTool of Windows SDK 10.0.22621 or newer under $kitsBin" }
+Write-Host "SignTool $((Get-Item $signtool.Path).VersionInfo.FileVersion): $($signtool.Path)"
+
+# ── 3. metadata.json ───────────────────────────────────────────────────────
+# Only the environment credential is tried. Without the exclusions the dlib
+# walks through every credential source Azure knows before it reaches the one
+# that exists on a hosted runner.
+$metadata = Join-Path $toolsDir 'metadata.json'
+[ordered]@{
+ Endpoint = $endpoint.TrimEnd('/')
+ CodeSigningAccountName = $account
+ CertificateProfileName = $certificateProfile
+ CorrelationId = "$env:GITHUB_REPOSITORY/$env:GITHUB_RUN_ID"
+ ExcludeCredentials = @(
+ 'ManagedIdentityCredential',
+ 'WorkloadIdentityCredential',
+ 'SharedTokenCacheCredential',
+ 'VisualStudioCredential',
+ 'VisualStudioCodeCredential',
+ 'AzureCliCredential',
+ 'AzurePowerShellCredential',
+ 'AzureDeveloperCliCredential',
+ 'InteractiveBrowserCredential'
+ )
+} | ConvertTo-Json | Set-Content -Path $metadata -Encoding utf8
+
+# ── 4. The Tauri overlay ───────────────────────────────────────────────────
+# The object form of signCommand, so the spaces in "Program Files (x86)" need
+# no quoting. %1 is the file the bundler wants signed. The timestamp server is
+# the one Microsoft names for this service; its certificates are valid for
+# three days, so a signature without a timestamp would expire with them.
+$overlayRel = 'src-tauri/tauri.signing.conf.json'
+$overlay = Join-Path $workspace $overlayRel
+[ordered]@{
+ bundle = [ordered]@{
+ windows = [ordered]@{
+ signCommand = [ordered]@{
+ cmd = $signtool.Path
+ args = @(
+ 'sign', '/v', '/fd', 'SHA256',
+ '/tr', 'http://timestamp.acs.microsoft.com', '/td', 'SHA256',
+ '/dlib', $dlib,
+ '/dmdf', $metadata,
+ '%1'
+ )
+ }
+ }
+ }
+} | ConvertTo-Json -Depth 6 | Set-Content -Path $overlay -Encoding utf8
+
+"config_args=--config $overlayRel" | Add-Content -Path $env:GITHUB_OUTPUT
+"signtool=$($signtool.Path)" | Add-Content -Path $env:GITHUB_OUTPUT
+Write-Host "Windows signing is configured: $overlayRel"
diff --git a/scripts/windows-signing-verify.ps1 b/scripts/windows-signing-verify.ps1
new file mode 100644
index 00000000..519dee9e
--- /dev/null
+++ b/scripts/windows-signing-verify.ps1
@@ -0,0 +1,139 @@
+# windows-signing-verify.ps1: did the signed Windows build come out signed?
+#
+# Runs after a signing lane of the Windows build, never on the unsigned path:
+# - Azure Artifact Signing (release.yml, after `tauri build` signed in place)
+# - SignPath (.github/actions/windows-signpath, after the second signing
+# request came back)
+# A configured lane that silently signed nothing must not look like a signed
+# release.
+#
+# Hard failures:
+# - an installer (NSIS .exe or .msi) without a valid, timestamped signature
+# - installers signed by different publishers
+# - with -ExpectedPublisher: a publisher whose certificate subject does not
+# contain that text
+# - an executable inside an installer that should be signed and is not.
+# Without -SignedExecutables that is every .exe inside the NSIS installer
+# (Azure signs them all). With it, only the named files: SignPath
+# Foundation certificates may sign binaries built from this repository's
+# own source only, so the bundled llama.cpp server and the NSIS
+# uninstaller stub stay unsigned on that lane, and are listed as such.
+# Warning only: a .dll inside the installer without a signature, because a
+# third party library may legitimately ship unsigned.
+#
+# -AllowTestCertificate is for SignPath's test-signing policy, whose
+# certificate is self-signed: Windows reports such a signature as present but
+# not trusted. With the switch that status passes, as long as a signer
+# certificate is attached and the file hash matches. Release builds never
+# pass it.
+#
+# What this cannot check is SmartScreen. Reputation is built by downloads, not
+# by a property of the file, so that stays a manual look on a clean machine.
+
+param(
+ [string]$BundleRoot = 'src-tauri/target/release/bundle',
+ [string]$SignTool = '',
+ [string]$ExpectedPublisher = '',
+ [string[]]$SignedExecutables = @(),
+ [switch]$AllowTestCertificate
+)
+
+$ErrorActionPreference = 'Stop'
+
+function Get-Signature([string]$Path) {
+ $signature = Get-AuthenticodeSignature -FilePath $Path
+ [pscustomobject]@{
+ Path = $Path
+ Status = [string]$signature.Status
+ Subject = if ($signature.SignerCertificate) { $signature.SignerCertificate.Subject } else { '' }
+ Timestamped = [bool]$signature.TimeStamperCertificate
+ }
+}
+
+# Valid always passes. A test certificate chains to a root Windows does not
+# know, which PowerShell reports as UnknownError or NotTrusted; NotSigned and
+# HashMismatch never pass.
+function Test-Signed($Signature) {
+ if ($Signature.Status -eq 'Valid') { return $true }
+ if ($AllowTestCertificate -and $Signature.Subject -and ($Signature.Status -in @('UnknownError', 'NotTrusted'))) { return $true }
+ return $false
+}
+
+# The inner files that must carry a signature, and the ones that only get listed.
+function Test-InnerFiles([string]$Directory, [string]$Origin) {
+ $unsigned = @()
+ $seen = @()
+ foreach ($file in Get-ChildItem -Path $Directory -Recurse -File -Include '*.exe', '*.dll') {
+ $signature = Get-Signature $file.FullName
+ $relative = $file.FullName.Substring($Directory.Length + 1)
+ $required = if ($SignedExecutables.Count -gt 0) { $SignedExecutables -contains $file.Name } else { $file.Extension -eq '.exe' }
+ if ($required) { $seen += $file.Name }
+ if (Test-Signed $signature) {
+ Write-Host "ok ${Origin}: $relative $($signature.Subject)"
+ if ($required -and $ExpectedPublisher -and ($signature.Subject -notlike "*$ExpectedPublisher*")) {
+ throw "${Origin}: $relative is signed by '$($signature.Subject)', expected a publisher containing '$ExpectedPublisher'"
+ }
+ } elseif ($required) {
+ Write-Host "::error::unsigned or invalid ($($signature.Status)): ${Origin}: $relative"
+ $unsigned += $relative
+ } elseif ($file.Extension -eq '.exe') {
+ Write-Host "unsigned by policy ($($signature.Status)): ${Origin}: $relative"
+ } else {
+ Write-Host "::warning::library without a valid signature ($($signature.Status)): ${Origin}: $relative"
+ }
+ }
+ if ($unsigned.Count -gt 0) { throw "executables inside $Origin are not signed: $($unsigned -join ', ')" }
+ foreach ($name in $SignedExecutables) {
+ if ($seen -notcontains $name) { throw "$Origin does not contain $name, which should be signed" }
+ }
+}
+
+$installers = @(Get-ChildItem -Path $BundleRoot -Recurse -File -Include '*-setup.exe', '*.msi')
+if ($installers.Count -eq 0) { throw "no NSIS or MSI installer under $BundleRoot" }
+
+$subjects = @()
+foreach ($installer in $installers) {
+ # SignTool applies the Windows trust policy, which a test certificate
+ # cannot pass by design.
+ if ($SignTool -and -not $AllowTestCertificate) {
+ & $SignTool verify /pa /v $installer.FullName
+ if ($LASTEXITCODE -ne 0) { throw "SignTool does not accept the signature of $($installer.Name)" }
+ }
+ $signature = Get-Signature $installer.FullName
+ if (-not (Test-Signed $signature)) { throw "$($installer.Name): signature status is $($signature.Status)" }
+ if (-not $signature.Timestamped) { throw "$($installer.Name): the signature has no timestamp" }
+ if ($ExpectedPublisher -and ($signature.Subject -notlike "*$ExpectedPublisher*")) {
+ throw "$($installer.Name) is signed by '$($signature.Subject)', expected a publisher containing '$ExpectedPublisher'"
+ }
+ Write-Host "ok $($installer.Name) $($signature.Subject)"
+ $subjects += $signature.Subject
+}
+$publishers = @($subjects | Sort-Object -Unique)
+if ($publishers.Count -ne 1) { throw "the installers are signed by different publishers: $($publishers -join ' | ')" }
+
+# The files a user ends up running sit inside the installers. 7-Zip, which the
+# runner image ships, unpacks an NSIS installer without running it.
+$setup = $installers | Where-Object { $_.Name -like '*-setup.exe' } | Select-Object -First 1
+if ($setup) {
+ $extractDir = Join-Path $env:RUNNER_TEMP 'nsis-extract'
+ if (Test-Path $extractDir) { Remove-Item -Recurse -Force $extractDir }
+ & 7z x "-o$extractDir" -y $setup.FullName | Out-Null
+ if ($LASTEXITCODE -ne 0) { throw "7-Zip could not unpack $($setup.Name)" }
+ Test-InnerFiles $extractDir $setup.Name
+}
+
+# The MSI is checked the same way where the caller names the files that must
+# be signed. An administrative install (msiexec /a) lays the files out in a
+# directory without installing anything.
+$msi = $installers | Where-Object { $_.Extension -eq '.msi' } | Select-Object -First 1
+if ($msi -and $SignedExecutables.Count -gt 0) {
+ $extractDir = Join-Path $env:RUNNER_TEMP 'msi-extract'
+ if (Test-Path $extractDir) { Remove-Item -Recurse -Force $extractDir }
+ New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
+ $process = Start-Process -FilePath 'msiexec.exe' -ArgumentList @('/a', "`"$($msi.FullName)`"", '/qn', "TARGETDIR=`"$extractDir`"") -Wait -PassThru
+ if ($process.ExitCode -ne 0) { throw "msiexec could not unpack $($msi.Name) (exit code $($process.ExitCode))" }
+ Test-InnerFiles $extractDir $msi.Name
+}
+
+"publisher=$($publishers[0])" | Add-Content -Path $env:GITHUB_OUTPUT
+Write-Host "OK: every installer carries a valid signature from $($publishers[0]), and so does every executable inside them that should"
diff --git a/scripts/windows-signpath.d.mts b/scripts/windows-signpath.d.mts
new file mode 100644
index 00000000..7ab6535a
--- /dev/null
+++ b/scripts/windows-signpath.d.mts
@@ -0,0 +1,33 @@
+/** Types for the plain-node module. The script runs in CI without a build
+ * step, so the implementation stays .mjs and the types live here. */
+
+export declare const BUNDLE_MARKER: string
+export declare const VARIANTS: { nsis: string; msi: string }
+
+export declare function patchBundleType(binary: Buffer, variant: string): Buffer
+export declare function bundleTypeOf(binary: Buffer): 'nsis' | 'msi' | null
+export declare function peCertificateTableSize(binary: Buffer): number
+export declare function zipOfOneFile(name: string, data: Buffer): Buffer
+export declare function releaseAssetName(fileName: string): string
+
+export interface UpdaterPlatform {
+ signature: string
+ url: string
+}
+export interface LatestJson {
+ version: string
+ notes?: string
+ pub_date?: string
+ platforms?: Record<string, UpdaterPlatform>
+}
+
+export declare function windowsPlatforms(
+ files: string[],
+ signatureOf: (file: string) => string,
+ downloadBaseUrl: string,
+): Record<string, UpdaterPlatform>
+export declare function mergeLatestJson(
+ existing: LatestJson | null,
+ platforms: Record<string, UpdaterPlatform>,
+ fallback: { version: string; notes: string; pubDate: string },
+): LatestJson
diff --git a/scripts/windows-signpath.mjs b/scripts/windows-signpath.mjs
new file mode 100644
index 00000000..a9be3a01
--- /dev/null
+++ b/scripts/windows-signpath.mjs
@@ -0,0 +1,316 @@
+#!/usr/bin/env node
+// windows-signpath.mjs: the file handling of the SignPath signing lane.
+//
+// SignPath signs artifacts that were uploaded to GitHub, after the build.
+// Tauri expects to sign during the build. This script is everything between
+// the two that is plain file work, so it can be tested without Windows and
+// without a SignPath account (src/lib/__tests__/windows-signpath.test.ts).
+// The steps that call it are in .github/actions/windows-signpath/action.yml.
+//
+// Why the app binary is staged twice. The bundler writes the installer type
+// into the main binary before it packs it (tauri-bundler 2.8.1, bundle.rs,
+// patch_binary): the marker __TAURI_BUNDLE_TYPE_VAR_UNK becomes ..._NSS for
+// the NSIS installer and ..._MSI for the MSI. The updater reads it to pick
+// "windows-x86_64-nsis" or "windows-x86_64-msi" from latest.json. Changing a
+// byte of a signed file breaks its signature, so the marker has to be written
+// BEFORE SignPath signs. `stage-app` therefore produces one copy per
+// installer type, both get signed, and `place-app` puts the right one where
+// `tauri bundle` looks. The bundler then finds no ..._UNK marker, logs a
+// warning, and packs the file as it is.
+//
+// Commands (paths are relative to the repository root unless absolute):
+// stage-app <out-dir> patched copies under nsis/ and msi/
+// place-app <nsis|msi> <signed-dir> signed copy into src-tauri/target/release
+// check-app <nsis|msi> <signed-dir> the bundler left that copy untouched
+// stage-installers <out-dir> the one NSIS and the one MSI installer
+// updater-artifacts <signed-dir> <dist-dir>
+// release file names plus the v1 zips
+// merge-latest-json <dist-dir> <latest.json> <download-base-url>
+// write the Windows entries into the file
+import { createHash } from 'node:crypto'
+import {
+ appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync,
+ statSync, writeFileSync,
+} from 'node:fs'
+import { basename, dirname, join, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { crc32 } from 'node:zlib'
+
+export const BUNDLE_MARKER = '__TAURI_BUNDLE_TYPE_VAR_'
+const UNPATCHED = `${BUNDLE_MARKER}UNK`
+/** The marker value the bundler writes per installer type. */
+export const VARIANTS = { nsis: `${BUNDLE_MARKER}NSS`, msi: `${BUNDLE_MARKER}MSI` }
+
+function fail(message) {
+ throw new Error(message)
+}
+
+/** Every offset at which `needle` starts in `haystack`. */
+function offsetsOf(haystack, needle) {
+ const found = []
+ const bytes = Buffer.from(needle, 'latin1')
+ for (let at = haystack.indexOf(bytes); at >= 0; at = haystack.indexOf(bytes, at + 1)) found.push(at)
+ return found
+}
+
+/**
+ * A copy of the app binary with the installer type written into it, the same
+ * way the bundler does it: the first ..._UNK marker is overwritten in place.
+ */
+export function patchBundleType(binary, variant) {
+ const value = VARIANTS[variant] ?? fail(`unknown installer type "${variant}", expected nsis or msi`)
+ const at = offsetsOf(binary, UNPATCHED)
+ if (at.length === 0) {
+ fail(`the app binary has no ${UNPATCHED} marker. It was either bundled already or built with a tauri crate that does not carry the marker; the updater could not tell NSIS from MSI.`)
+ }
+ const patched = Buffer.from(binary)
+ patched.write(value, at[0], 'latin1')
+ return patched
+}
+
+/** Which installer type a binary is marked for: "nsis", "msi", or null. */
+export function bundleTypeOf(binary) {
+ for (const [variant, value] of Object.entries(VARIANTS)) {
+ if (offsetsOf(binary, value).length > 0) return variant
+ }
+ return null
+}
+
+/**
+ * Size of the certificate table of a PE file, 0 when it carries no
+ * Authenticode signature. This says "a signature is attached", not "the
+ * signature is valid"; validity is checked on Windows by
+ * scripts/windows-signing-verify.ps1.
+ */
+export function peCertificateTableSize(binary) {
+ if (binary.length < 0x40 || binary.toString('latin1', 0, 2) !== 'MZ') fail('not a PE file: no MZ header')
+ const pe = binary.readUInt32LE(0x3c)
+ if (pe + 24 > binary.length || binary.toString('latin1', pe, pe + 4) !== 'PE\0\0') fail('not a PE file: no PE header')
+ const optional = pe + 24
+ const magic = binary.readUInt16LE(optional)
+ const directories = magic === 0x20b ? optional + 112 : magic === 0x10b ? optional + 96 : fail(`unknown PE optional header magic 0x${magic.toString(16)}`)
+ const security = directories + 4 * 8
+ if (security + 8 > binary.length) fail('not a PE file: the data directories are cut off')
+ return binary.readUInt32LE(security + 4)
+}
+
+/** A ZIP archive holding one file, stored, as tauri-bundler writes its v1 updater archives. */
+export function zipOfOneFile(name, data) {
+ if (data.length >= 0xffffffff) fail(`${name} is too large for a plain ZIP archive`)
+ const fileName = Buffer.from(name, 'utf8')
+ const checksum = crc32(data)
+ // 0x0800: the file name is UTF-8.
+ const flags = 0x0800
+ const local = Buffer.alloc(30)
+ local.writeUInt32LE(0x04034b50, 0)
+ local.writeUInt16LE(20, 4)
+ local.writeUInt16LE(flags, 6)
+ local.writeUInt16LE(0, 8)
+ local.writeUInt16LE(0, 10)
+ local.writeUInt16LE(0x21, 12)
+ local.writeUInt32LE(checksum, 14)
+ local.writeUInt32LE(data.length, 18)
+ local.writeUInt32LE(data.length, 22)
+ local.writeUInt16LE(fileName.length, 26)
+ local.writeUInt16LE(0, 28)
+ const central = Buffer.alloc(46)
+ central.writeUInt32LE(0x02014b50, 0)
+ central.writeUInt16LE(20, 4)
+ central.writeUInt16LE(20, 6)
+ central.writeUInt16LE(flags, 8)
+ central.writeUInt16LE(0, 10)
+ central.writeUInt16LE(0, 12)
+ central.writeUInt16LE(0x21, 14)
+ central.writeUInt32LE(checksum, 16)
+ central.writeUInt32LE(data.length, 20)
+ central.writeUInt32LE(data.length, 24)
+ central.writeUInt16LE(fileName.length, 28)
+ central.writeUInt32LE(0, 42)
+ const end = Buffer.alloc(22)
+ end.writeUInt32LE(0x06054b50, 0)
+ end.writeUInt16LE(1, 8)
+ end.writeUInt16LE(1, 10)
+ end.writeUInt32LE(central.length + fileName.length, 12)
+ end.writeUInt32LE(local.length + fileName.length + data.length, 16)
+ return Buffer.concat([local, fileName, data, central, fileName, end])
+}
+
+/** GitHub replaces spaces in asset names with dots; do it before the upload so the names are known. */
+export function releaseAssetName(fileName) {
+ return fileName.replace(/ /g, '.')
+}
+
+/**
+ * The Windows entries of latest.json, in the shape tauri-action writes them
+ * for createUpdaterArtifacts "v1Compatible" (read from the v3.0.5 release):
+ * the plain key points at the zipped MSI for updaters older than the
+ * installer-type lookup, the two suffixed keys at the installers themselves.
+ */
+export function windowsPlatforms(files, signatureOf, downloadBaseUrl) {
+ const one = (pattern, what) => {
+ const hits = files.filter((f) => pattern.test(f))
+ if (hits.length !== 1) fail(`expected exactly one ${what}, found ${hits.length}: ${hits.join(', ')}`)
+ return hits[0]
+ }
+ const entry = (file) => ({
+ signature: signatureOf(file),
+ url: `${downloadBaseUrl.replace(/\/$/, '')}/${encodeURIComponent(file)}`,
+ })
+ return {
+ 'windows-x86_64': entry(one(/\.msi\.zip$/, 'zipped MSI')),
+ 'windows-x86_64-msi': entry(one(/\.msi$/, 'MSI installer')),
+ 'windows-x86_64-nsis': entry(one(/-setup\.exe$/, 'NSIS installer')),
+ }
+}
+
+/** latest.json with the Windows entries replaced, everything else kept. */
+export function mergeLatestJson(existing, platforms, fallback) {
+ const merged = existing ? structuredClone(existing) : { version: fallback.version, notes: fallback.notes, pub_date: fallback.pubDate }
+ if (existing && existing.version !== fallback.version) {
+ fail(`latest.json on the release says version ${existing.version}, this build is ${fallback.version}`)
+ }
+ merged.platforms = { ...(merged.platforms ?? {}), ...platforms }
+ return merged
+}
+
+// ── Command line ───────────────────────────────────────────────────────────
+
+const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
+
+function appBinaryName() {
+ const cargo = readFileSync(join(root, 'src-tauri/Cargo.toml'), 'utf8')
+ const name = /^\[package\][^[]*?^name\s*=\s*"([^"]+)"/ms.exec(cargo)?.[1] ?? fail('no package name in src-tauri/Cargo.toml')
+ return `${name}.exe`
+}
+
+function appVersion() {
+ return JSON.parse(readFileSync(join(root, 'src-tauri/tauri.conf.json'), 'utf8')).version
+}
+
+const builtApp = () => join(root, 'src-tauri/target/release', appBinaryName())
+const sha256 = (file) => createHash('sha256').update(readFileSync(file)).digest('hex')
+
+function output(name, value) {
+ if (process.env.GITHUB_OUTPUT) appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`)
+ console.log(`${name}=${value}`)
+}
+
+function freshDir(dir) {
+ rmSync(dir, { recursive: true, force: true })
+ mkdirSync(dir, { recursive: true })
+}
+
+function signedCopy(variant, signedDir) {
+ const file = join(resolve(signedDir), variant, appBinaryName())
+ if (!existsSync(file)) fail(`SignPath returned no ${variant}/${appBinaryName()} in ${signedDir}`)
+ return file
+}
+
+function onlyFile(dir, pattern, what) {
+ const hits = existsSync(dir) ? readdirSync(dir).filter((f) => pattern.test(f)) : []
+ if (hits.length !== 1) fail(`expected exactly one ${what} in ${dir}, found ${hits.length}: ${hits.join(', ')}`)
+ return join(dir, hits[0])
+}
+
+const commands = {
+ 'stage-app'([outDir]) {
+ const out = resolve(outDir ?? fail('usage: stage-app <out-dir>'))
+ const binary = readFileSync(builtApp())
+ if (peCertificateTableSize(binary) !== 0) fail(`${builtApp()} is already signed; SignPath must receive the unsigned build`)
+ freshDir(out)
+ for (const variant of Object.keys(VARIANTS)) {
+ mkdirSync(join(out, variant))
+ writeFileSync(join(out, variant, appBinaryName()), patchBundleType(binary, variant))
+ }
+ output('dir', out)
+ output('version', appVersion())
+ output('binary', appBinaryName())
+ },
+
+ 'place-app'([variant, signedDir]) {
+ const signed = signedCopy(variant, signedDir ?? fail('usage: place-app <nsis|msi> <signed-dir>'))
+ const binary = readFileSync(signed)
+ if (peCertificateTableSize(binary) === 0) fail(`${signed} came back from SignPath without a signature`)
+ if (bundleTypeOf(binary) !== variant) fail(`${signed} is not marked for the ${variant} installer`)
+ copyFileSync(signed, builtApp())
+ console.log(`placed the signed ${variant} build of ${appBinaryName()} (sha256 ${sha256(signed)})`)
+ },
+
+ 'check-app'([variant, signedDir]) {
+ const signed = signedCopy(variant, signedDir ?? fail('usage: check-app <nsis|msi> <signed-dir>'))
+ if (sha256(signed) !== sha256(builtApp())) {
+ fail(`the bundler changed ${appBinaryName()} while packing the ${variant} installer; its signature no longer covers the file`)
+ }
+ console.log(`the bundler packed the signed ${variant} build of ${appBinaryName()} unchanged`)
+ },
+
+ 'stage-installers'([outDir]) {
+ const out = resolve(outDir ?? fail('usage: stage-installers <out-dir>'))
+ const bundle = join(root, 'src-tauri/target/release/bundle')
+ const nsis = onlyFile(join(bundle, 'nsis'), /-setup\.exe$/, 'NSIS installer')
+ const msi = onlyFile(join(bundle, 'msi'), /\.msi$/, 'MSI installer')
+ freshDir(out)
+ for (const file of [nsis, msi]) copyFileSync(file, join(out, basename(file)))
+ output('dir', out)
+ },
+
+ 'updater-artifacts'([signedDir, distDir]) {
+ if (!signedDir || !distDir) fail('usage: updater-artifacts <signed-dir> <dist-dir>')
+ const signed = resolve(signedDir)
+ const dist = resolve(distDir)
+ const nsis = onlyFile(signed, /-setup\.exe$/, 'signed NSIS installer')
+ const msi = onlyFile(signed, /\.msi$/, 'signed MSI installer')
+ if (peCertificateTableSize(readFileSync(nsis)) === 0) fail(`${nsis} came back from SignPath without a signature`)
+ freshDir(dist)
+ // tauri-bundler names the archive after the installer with the bundle
+ // type in place of the extension: -setup.exe -> -setup.nsis.zip, and
+ // .msi -> .msi.zip. The file inside keeps its original name.
+ for (const [file, zipName] of [
+ [nsis, basename(nsis).replace(/\.exe$/, '.nsis.zip')],
+ [msi, `${basename(msi)}.zip`],
+ ]) {
+ const data = readFileSync(file)
+ writeFileSync(join(dist, releaseAssetName(basename(file))), data)
+ writeFileSync(join(dist, releaseAssetName(zipName)), zipOfOneFile(basename(file), data))
+ }
+ output('dir', dist)
+ },
+
+ 'merge-latest-json'([distDir, latestJson, downloadBaseUrl]) {
+ if (!distDir || !latestJson || !downloadBaseUrl) fail('usage: merge-latest-json <dist-dir> <latest.json> <download-base-url>')
+ const dist = resolve(distDir)
+ const files = readdirSync(dist).filter((f) => statSync(join(dist, f)).isFile())
+ const signatureOf = (file) => {
+ const sig = join(dist, `${file}.sig`)
+ if (!existsSync(sig)) fail(`${file} has no updater signature (${file}.sig)`)
+ return readFileSync(sig, 'utf8').trim()
+ }
+ const platforms = windowsPlatforms(files.filter((f) => !f.endsWith('.sig')), signatureOf, downloadBaseUrl)
+ const target = resolve(latestJson)
+ const existing = existsSync(target) ? JSON.parse(readFileSync(target, 'utf8')) : null
+ const merged = mergeLatestJson(existing, platforms, {
+ version: appVersion(),
+ notes: process.env.RELEASE_NOTES ?? '',
+ pubDate: new Date().toISOString(),
+ })
+ writeFileSync(target, `${JSON.stringify(merged, null, 2)}\n`)
+ console.log(`latest.json: ${Object.keys(platforms).join(', ')} now point at the signed installers`)
+ },
+}
+
+// Run as a program, not imported. Both sides resolved, because a temporary
+// directory is often reached through a symbolic link.
+if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) {
+ const [command, ...args] = process.argv.slice(2)
+ const run = commands[command]
+ if (!run) {
+ console.error(`usage: windows-signpath.mjs <${Object.keys(commands).join('|')}> ...`)
+ process.exit(2)
+ }
+ try {
+ run(args)
+ } catch (error) {
+ console.error(`::error::${error.message}`)
+ process.exit(1)
+ }
+}
diff --git a/src-tauri/Entitlements.minimal.plist b/src-tauri/Entitlements.minimal.plist
new file mode 100644
index 00000000..790f2850
--- /dev/null
+++ b/src-tauri/Entitlements.minimal.plist
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!--
+ CANDIDATE, not in use. tauri.conf.json points at Entitlements.plist.
+
+ The smallest set a Developer ID build of LU is expected to need: the
+ microphone, and no Hardened Runtime exception at all. Apple runs extra
+ Gatekeeper checks on programs that disable library validation, and asks for
+ only the entitlements an app cannot work without, so this is where the
+ release build should end up.
+
+ It has not run in any build. Before tauri.conf.json is switched to it, one
+ Hardened Runtime build has to pass these by hand (the Hardened Runtime is
+ enforced for an ad hoc signature too, so no certificate is needed for the
+ test): the window renders and chat streams, the bundled engine loads a model
+ and answers, dictation and a voice session hear the microphone, MLX image
+ generation starts, an update installs. When it passes, this content replaces
+ Entitlements.plist and this file goes away.
+-->
+<plist version="1.0">
+<dict>
+ <key>com.apple.security.device.audio-input</key>
+ <true/>
+</dict>
+</plist>
diff --git a/src-tauri/Entitlements.plist b/src-tauri/Entitlements.plist
index 38672e1d..9ec69dbe 100644
--- a/src-tauri/Entitlements.plist
+++ b/src-tauri/Entitlements.plist
@@ -1,16 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
- Hardened Runtime entitlements (referenced via bundle.macOS.entitlements in
- tauri.conf.json; derived from the proven LU-Labs bridge set).
+ Entitlements of the macOS build (bundle.macOS.entitlements in
+ tauri.conf.json). The bundler applies this one file to the main binary AND
+ to every externalBin, so lu-llama-server runs with the same set.
- - allow-jit + allow-unsigned-executable-memory: WKWebView JavaScriptCore JIT.
- - disable-library-validation: whisper/voice sidecar loads Python dylibs not
- signed with our identity.
- - network.client: Ollama/LM-Studio probes, Hugging Face + Civitai downloads.
- - network.server: remote-access bridge listens on port 19191.
- - device.audio-input: microphone for dictation/voice — required in a
- notarized Hardened Runtime build even with NSMicrophoneUsageDescription.
+ The app is signed with the Hardened Runtime (tauri's default), ad hoc in a
+ local build and with a Developer ID in the release lane. The first three keys
+ are exceptions to it, and each one switches a protection off. The set below
+ is the one every Mac build so far has run with. Which of the three a
+ notarized build still needs has not been measured; Entitlements.minimal.plist
+ is the candidate to test before any of them is dropped.
+
+ - cs.allow-jit, cs.allow-unsigned-executable-memory: kept from the LU-Labs
+ bridge set. WKWebView runs its JavaScript JIT in Apple's own WebContent
+ process, not in this one, so the app itself is not expected to need them.
+ - cs.disable-library-validation: lets this process load libraries that are
+ not signed by Apple or by our team. Nothing in the bundle is such a
+ library. The Python the voice and MLX sidecars run on is a separate
+ program in a separate process and is not governed by this file at all.
+ - network.client, network.server: App Sandbox keys. The app is not
+ sandboxed, so they have no effect and only document what the app does
+ (model downloads, local backends, the remote access listener).
+ - device.audio-input: the microphone, for dictation and voice. Required
+ under the Hardened Runtime in addition to NSMicrophoneUsageDescription.
+
+ Computer control needs no key here: Accessibility and Screen Recording are
+ granted by the user in System Settings, to the signed identity of the app.
-->
<plist version="1.0">
<dict>
diff --git a/src/lib/__tests__/release-build-gate.test.ts b/src/lib/__tests__/release-build-gate.test.ts
index d917b130..7c120161 100644
--- a/src/lib/__tests__/release-build-gate.test.ts
+++ b/src/lib/__tests__/release-build-gate.test.ts
@@ -213,7 +213,9 @@ describe('a longer gate must not mean a longer window at Latest', () => {
// run when the build FAILED, which is when leaving the flag on would be
// worst, and it is what holds the promise on a manual re-run.
expect(late).not.toBe('')
- expect(late).toMatch(/^\s*needs:\s*build-tauri\s*$/m)
+ // Both build jobs: the macOS one may be skipped (no Apple secrets), and
+ // `always()` below covers that as it covers a failed lane.
+ expect(late).toMatch(/^\s*needs:\s*\[build-tauri, build-macos\]\s*$/m)
expect(late).toMatch(/^\s*if:\s*always\(\)\s*$/m)
expect(late).toContain('node scripts/enforce-prerelease.mjs')
})
diff --git a/src/lib/__tests__/release-rules.test.ts b/src/lib/__tests__/release-rules.test.ts
index 2c362d0c..972f713f 100644
--- a/src/lib/__tests__/release-rules.test.ts
+++ b/src/lib/__tests__/release-rules.test.ts
@@ -160,7 +160,7 @@ describe('the workflow actually calls it', () => {
it('after the binaries are attached, not before', () => {
expect(wf).toContain('enforce-prerelease:')
- expect(wf).toContain('needs: build-tauri')
+ expect(wf).toContain('needs: [build-tauri, build-macos]')
expect(wf).toContain('node scripts/enforce-prerelease.mjs')
})
diff --git a/src/lib/__tests__/signing-lanes.test.ts b/src/lib/__tests__/signing-lanes.test.ts
new file mode 100644
index 00000000..78711c71
--- /dev/null
+++ b/src/lib/__tests__/signing-lanes.test.ts
@@ -0,0 +1,441 @@
+/**
+ * Code signing switches on by secrets, and without them nothing changes.
+ *
+ * release.yml carries three signing lanes that are prepared but dormant: two
+ * for the Windows installers, Azure Artifact Signing and SignPath, of which a
+ * release can take only one, and a Developer ID signed, notarized macOS
+ * build. The promise this file holds is the one that makes it safe to merge
+ * them before any account exists: with no signing secret in the repository, a
+ * release run builds what it built before, unsigned Windows and Linux
+ * installers and no macOS asset, and stays green. A fork is in that state
+ * permanently.
+ *
+ * Two halves, like release-build-gate.test.ts:
+ *
+ * 1. Behaviour. scripts/signing-config.sh is the one place that decides
+ * whether a lane is on. It is EXECUTED here in a real bash with the
+ * secret combinations that matter, including the half-filled ones, which
+ * must count as absent and say so. The notarization hand-over of
+ * scripts/macos-release-signing.sh is executed the same way.
+ *
+ * 2. Structure. The workflow conditions every signing step on that script's
+ * answer and has no other path to a signature or to a macOS build.
+ *
+ * VERIFICATION LIMIT, stated on purpose: no GitHub Actions run was permitted
+ * and no certificate exists yet. No lane has ever signed anything. What
+ * is proven is the decision logic (by execution), the workflow's syntax
+ * (actionlint 1.7.12 with shellcheck 0.11.0) and the structural claims below.
+ *
+ * Run: npx vitest run src/lib/__tests__/signing-lanes.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { execFileSync } from 'node:child_process'
+import { readFileSync, mkdtempSync, rmSync, existsSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve, join } from 'node:path'
+import { bashInterpreter } from '../../api/__tests__/bash-interpreter'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const root = resolve(here, '../../..')
+const read = (rel: string) => readFileSync(resolve(root, rel), 'utf8')
+
+const RELEASE_YML = read('.github/workflows/release.yml')
+const BASH = bashInterpreter()
+
+/** The lines of one job, by indentation: jobs sit at two spaces under `jobs:`. */
+function jobBlock(yaml: string, job: string): string {
+ const lines = yaml.split(/\r?\n/)
+ const start = lines.findIndex((l) => l === ` ${job}:`)
+ if (start < 0) return ''
+ let end = lines.length
+ for (let i = start + 1; i < lines.length; i++) {
+ const l = lines[i]
+ if (/^ {2}[^\s#]/.test(l)) { end = i; break }
+ if (/^\S/.test(l) && l.trim() !== '') { end = i; break }
+ }
+ return lines.slice(start, end).join('\n')
+}
+
+/** Prose removed, so a rule cannot be satisfied by a comment about the rule. */
+function withoutComments(block: string): string {
+ return block
+ .split(/\r?\n/)
+ .filter((l) => !/^\s*#/.test(l))
+ .map((l) => l.replace(/\s#.*$/, ''))
+ .join('\n')
+}
+
+/** One step of a job: from its `- name:` line to the next step. */
+function stepBlock(job: string, name: string): string {
+ const lines = job.split(/\r?\n/)
+ const start = lines.findIndex((l) => l.trim() === `- name: ${name}`)
+ if (start < 0) return ''
+ const indent = lines[start].indexOf('-')
+ let end = lines.length
+ for (let i = start + 1; i < lines.length; i++) {
+ if (lines[i].startsWith(`${' '.repeat(indent)}- `)) { end = i; break }
+ }
+ return lines.slice(start, end).join('\n')
+}
+
+type Answer = { macos: string; macos_notary: string; windows: string; signpath: string; log: string }
+
+/** Runs signing-config.sh with exactly the given secrets and nothing inherited. */
+function decide(secrets: Record<string, string>, scope: 'macos' | 'windows' | null = null): Answer {
+ const dir = mkdtempSync(join(tmpdir(), 'signing-config-'))
+ const outFile = join(dir, 'out')
+ try {
+ const log = execFileSync(BASH, [resolve(root, 'scripts/signing-config.sh'), ...(scope ? [scope] : [])], {
+ encoding: 'utf8',
+ env: { PATH: process.env.PATH ?? '', GITHUB_OUTPUT: outFile, ...secrets },
+ })
+ const out = Object.fromEntries(
+ readFileSync(outFile, 'utf8').split(/\r?\n/).filter(Boolean).map((l) => {
+ const at = l.indexOf('=')
+ return [l.slice(0, at), l.slice(at + 1)]
+ }),
+ )
+ return { macos: out.macos, macos_notary: out.macos_notary, windows: out.windows, signpath: out.signpath, log }
+ } finally {
+ rmSync(dir, { recursive: true, force: true })
+ }
+}
+
+const CERT = { APPLE_CERTIFICATE: 'cGxhY2Vob2xkZXI=', APPLE_CERTIFICATE_PASSWORD: 'placeholder' }
+const API = { APPLE_API_KEY: 'KEYID', APPLE_API_ISSUER: 'issuer', APPLE_API_KEY_P8: 'placeholder' }
+const APPLE_ID = { APPLE_ID: '[email protected]', APPLE_PASSWORD: 'placeholder', APPLE_TEAM_ID: 'TEAMID' }
+const AZURE = {
+ AZURE_TENANT_ID: 't', AZURE_CLIENT_ID: 'c', AZURE_CLIENT_SECRET: 'placeholder',
+ ARTIFACT_SIGNING_ENDPOINT: 'https://weu.codesigning.azure.net',
+ ARTIFACT_SIGNING_ACCOUNT: 'account', ARTIFACT_SIGNING_PROFILE: 'profile',
+}
+const SIGNPATH = {
+ SIGNPATH_API_TOKEN: 'placeholder', SIGNPATH_ORGANIZATION_ID: '00000000-0000-0000-0000-000000000000',
+ SIGNPATH_PROJECT_SLUG: 'project', SIGNPATH_SIGNING_POLICY_SLUG: 'test-signing',
+}
+
+// ── 1. Behaviour ───────────────────────────────────────────────────────────
+
+describe('signing-config.sh, executed', () => {
+ it('with no secret at all, every lane is off and nothing is warned about', () => {
+ const answer = decide({})
+ expect(answer).toMatchObject({ macos: 'false', macos_notary: '', windows: 'false', signpath: 'false' })
+ expect(answer.log).not.toContain('::warning')
+ expect(answer.log).not.toContain('::error')
+ })
+
+ it('an empty secret is an absent secret, which is how GitHub hands over a missing one', () => {
+ const blank = Object.fromEntries(Object.keys({ ...CERT, ...API, ...APPLE_ID, ...AZURE, ...SIGNPATH }).map((k) => [k, '']))
+ expect(decide(blank)).toMatchObject({ macos: 'false', windows: 'false', signpath: 'false' })
+ })
+
+ it('macOS switches on with the certificate and an API key', () => {
+ expect(decide({ ...CERT, ...API })).toMatchObject({ macos: 'true', macos_notary: 'api', windows: 'false' })
+ })
+
+ it('or with the certificate and an Apple ID', () => {
+ expect(decide({ ...CERT, ...APPLE_ID })).toMatchObject({ macos: 'true', macos_notary: 'appleid' })
+ })
+
+ it('and prefers the API key when both are complete', () => {
+ expect(decide({ ...CERT, ...API, ...APPLE_ID }).macos_notary).toBe('api')
+ })
+
+ it('a certificate without notarization credentials stays off, with a warning that names what is missing', () => {
+ const answer = decide({ ...CERT, APPLE_ID: '[email protected]' })
+ expect(answer.macos).toBe('false')
+ expect(answer.log).toContain('::warning title=macOS signing is off::')
+ expect(answer.log).toContain('APPLE_PASSWORD APPLE_TEAM_ID')
+ })
+
+ it('notarization credentials without the certificate stay off, with a warning', () => {
+ const answer = decide({ ...API })
+ expect(answer.macos).toBe('false')
+ expect(answer.log).toContain('::warning title=macOS signing is off::')
+ expect(answer.log).toContain('APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD')
+ })
+
+ it('Azure switches on only with all six values', () => {
+ expect(decide({ ...AZURE })).toMatchObject({ windows: 'true', signpath: 'false', macos: 'false' })
+ for (const leftOut of Object.keys(AZURE)) {
+ const partial: Record<string, string> = { ...AZURE }
+ delete partial[leftOut]
+ const answer = decide(partial)
+ expect(answer.windows, leftOut).toBe('false')
+ expect(answer.log, leftOut).toContain('::warning title=Azure Artifact Signing is off::')
+ expect(answer.log, leftOut).toContain(leftOut)
+ }
+ })
+
+ it('SignPath switches on only with the token and all three identifiers', () => {
+ expect(decide({ ...SIGNPATH })).toMatchObject({ signpath: 'true', windows: 'false', macos: 'false' })
+ for (const leftOut of Object.keys(SIGNPATH)) {
+ const partial: Record<string, string> = { ...SIGNPATH }
+ delete partial[leftOut]
+ const answer = decide(partial)
+ expect(answer.signpath, leftOut).toBe('false')
+ expect(answer.log, leftOut).toContain('::warning title=SignPath signing is off::')
+ expect(answer.log, leftOut).toContain(leftOut)
+ }
+ })
+
+ it('with both Windows lanes complete the run stops, and says why in English', () => {
+ // execFileSync throws on a non-zero exit; stdout carries the annotation.
+ let stopped: { status?: number; stdout?: string } = {}
+ try {
+ decide({ ...AZURE, ...SIGNPATH }, 'windows')
+ } catch (error) {
+ stopped = error as typeof stopped
+ }
+ expect(stopped.status).toBe(1)
+ expect(stopped.stdout).toContain('::error title=Two Windows signing lanes are configured::')
+ expect(stopped.stdout).toContain('signed by exactly one of them')
+ })
+
+ it('a half-filled second lane does not stop the complete one', () => {
+ const azure = decide({ ...AZURE, SIGNPATH_ORGANIZATION_ID: 'o' }, 'windows')
+ expect(azure).toMatchObject({ windows: 'true', signpath: 'false' })
+ expect(azure.log).toContain('::warning title=SignPath signing is off::')
+ const signpath = decide({ ...SIGNPATH, AZURE_TENANT_ID: 't' }, 'windows')
+ expect(signpath).toMatchObject({ windows: 'false', signpath: 'true' })
+ expect(signpath.log).toContain('::warning title=Azure Artifact Signing is off::')
+ })
+
+ it('asked for one lane, it answers and warns for that lane alone', () => {
+ // release.yml hands each job only its own secrets. The macOS job must not
+ // report on Windows, and a half-filled Azure set is not its business.
+ const everything = { ...CERT, ...API, AZURE_TENANT_ID: 't' }
+ const mac = decide(everything, 'macos')
+ expect(mac).toMatchObject({ macos: 'true', macos_notary: 'api' })
+ expect(mac.windows).toBeUndefined()
+ expect(mac.signpath).toBeUndefined()
+ expect(mac.log).not.toContain('Windows')
+ const win = decide({ ...AZURE, APPLE_ID: '[email protected]' }, 'windows')
+ expect(win.windows).toBe('true')
+ expect(win.macos).toBeUndefined()
+ expect(win.log).not.toContain('macOS')
+ })
+
+ it('never prints a value it was given', () => {
+ const marked = Object.fromEntries(
+ Object.keys({ ...CERT, ...API, ...APPLE_ID, ...AZURE }).map((k) => [k, `SECRET-VALUE-OF-${k}`]),
+ )
+ const answer = decide(marked)
+ expect(answer.log).not.toContain('SECRET-VALUE-OF-')
+ const signpath = Object.fromEntries(Object.keys(SIGNPATH).map((k) => [k, `SECRET-VALUE-OF-${k}`]))
+ expect(decide(signpath).log).not.toContain('SECRET-VALUE-OF-')
+ })
+})
+
+describe('the notarization hand-over, executed', () => {
+ // tauri-bundler tests the Apple ID variables for "is set" before it looks at
+ // the API key, so an empty APPLE_ID next to a real API key would be used.
+ // `prepare` must export one set and leave the other names out entirely.
+ function prepare(env: Record<string, string>): string {
+ const dir = mkdtempSync(join(tmpdir(), 'notary-env-'))
+ const envFile = join(dir, 'env')
+ try {
+ execFileSync(BASH, [resolve(root, 'scripts/macos-release-signing.sh'), 'prepare'], {
+ encoding: 'utf8',
+ env: { PATH: process.env.PATH ?? '', GITHUB_ENV: envFile, RUNNER_TEMP: dir, ...env },
+ })
+ const written = readFileSync(envFile, 'utf8')
+ const keyLine = written.split(/\r?\n/).find((l) => l.startsWith('APPLE_API_KEY_PATH='))
+ if (keyLine) {
+ const keyPath = keyLine.slice('APPLE_API_KEY_PATH='.length)
+ expect(existsSync(keyPath)).toBe(true)
+ expect(readFileSync(keyPath, 'utf8')).toContain('BEGIN PRIVATE KEY')
+ }
+ return written
+ } finally {
+ rmSync(dir, { recursive: true, force: true })
+ }
+ }
+
+ // Not a key: a marker between the two PEM lines the script looks for.
+ const P8 = '-----BEGIN PRIVATE KEY-----\nbm90IGEga2V5\n-----END PRIVATE KEY-----'
+ const all = {
+ NOTARY_API_KEY: 'KEYID', NOTARY_API_ISSUER: 'issuer', NOTARY_API_KEY_P8: P8,
+ NOTARY_APPLE_ID: '[email protected]', NOTARY_APPLE_PASSWORD: 'placeholder', EXPECTED_TEAM_ID: 'TEAMID',
+ }
+ const names = (written: string) => written.split(/\r?\n/).filter(Boolean).map((l) => l.slice(0, l.indexOf('='))).sort()
+
+ it('api mode exports the API key set and no Apple ID variable', () => {
+ expect(names(prepare({ ...all, NOTARY_MODE: 'api' }))).toEqual(['APPLE_API_ISSUER', 'APPLE_API_KEY', 'APPLE_API_KEY_PATH'])
+ })
+
+ it('api mode also takes the key file as base64', () => {
+ const encoded = Buffer.from(P8, 'utf8').toString('base64')
+ expect(names(prepare({ ...all, NOTARY_API_KEY_P8: encoded, NOTARY_MODE: 'api' }))).toContain('APPLE_API_KEY_PATH')
+ })
+
+ it('appleid mode exports the Apple ID set and no API key variable', () => {
+ expect(names(prepare({ ...all, NOTARY_MODE: 'appleid' }))).toEqual(['APPLE_ID', 'APPLE_PASSWORD', 'APPLE_TEAM_ID'])
+ })
+
+ it('refuses a mode it was not told', () => {
+ expect(() => prepare({ ...all, NOTARY_MODE: '' })).toThrow()
+ })
+})
+
+// ── 2. Structure ───────────────────────────────────────────────────────────
+
+describe('release.yml signs only where signing-config.sh said yes', () => {
+ const build = jobBlock(RELEASE_YML, 'build-tauri')
+ const mac = jobBlock(RELEASE_YML, 'build-macos')
+ const config = jobBlock(RELEASE_YML, 'signing-config')
+
+ it('the macOS job exists only behind the detected secrets', () => {
+ expect(mac, 'no `build-macos` job in release.yml').not.toBe('')
+ expect(withoutComments(mac)).toMatch(/^\s{4}if:\s*needs\.signing-config\.outputs\.macos == 'true'\s*$/m)
+ expect(withoutComments(mac)).toMatch(/^\s{4}needs:\s*\[gate, signing-config\]\s*$/m)
+ expect(config).toContain('bash scripts/signing-config.sh macos')
+ })
+
+ it('and has no unsigned fallback: the build step always carries the certificate', () => {
+ const step = stepBlock(mac, 'Build, sign, notarize and release the macOS app')
+ expect(step).toContain('APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}')
+ expect(step).toMatch(/APPLE_SIGNING_IDENTITY: \$\{\{ secrets\.APPLE_SIGNING_IDENTITY \|\| 'Developer ID Application' \}\}/)
+ // The notarization variables reach the build through $GITHUB_ENV only.
+ for (const name of ['APPLE_ID', 'APPLE_PASSWORD', 'APPLE_TEAM_ID', 'APPLE_API_KEY', 'APPLE_API_ISSUER', 'APPLE_API_KEY_PATH']) {
+ expect(withoutComments(step), name).not.toMatch(new RegExp(`^\\s*${name}:`, 'm'))
+ }
+ })
+
+ it('the macOS job proves its result before it replaces the disk image', () => {
+ const finish = mac.indexOf('bash scripts/macos-release-signing.sh finish')
+ const upload = mac.indexOf('gh release upload')
+ expect(finish).toBeGreaterThan(0)
+ expect(upload).toBeGreaterThan(finish)
+ expect(withoutComments(mac)).not.toMatch(/continue-on-error/)
+ expect(withoutComments(mac)).not.toMatch(/\|\|\s*true/)
+ })
+
+ it('the Windows signing steps are skipped without the Azure secrets', () => {
+ const condition = "if: matrix.platform == 'windows-latest' && steps.signcfg.outputs.windows == 'true'"
+ expect(stepBlock(build, 'Configure Windows code signing (Azure Artifact Signing)')).toContain(condition)
+ expect(stepBlock(build, 'Verify the Windows signatures')).toContain(condition)
+ expect(stepBlock(build, 'Which Windows signing secrets are present')).toContain('bash scripts/signing-config.sh windows')
+ })
+
+ it('the SignPath steps are skipped without the SignPath values', () => {
+ const condition = "if: matrix.platform == 'windows-latest' && steps.signcfg.outputs.signpath == 'true'"
+ const sign = stepBlock(build, 'Build and sign the Windows installers (SignPath)')
+ expect(sign).toContain(condition)
+ expect(sign).toContain('uses: ./.github/actions/windows-signpath')
+ expect(stepBlock(build, 'Attach the signed Windows installers and update latest.json')).toContain(condition)
+ // The token is handed to that one step and to the detection, nowhere else.
+ const tokenLines = withoutComments(RELEASE_YML).split(/\r?\n/).filter((l) => l.includes('secrets.SIGNPATH_API_TOKEN'))
+ expect(tokenLines.map((l) => l.trim()).sort()).toEqual([
+ 'SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }}',
+ 'api-token: ${{ secrets.SIGNPATH_API_TOKEN }}',
+ ])
+ })
+
+ it('the ordinary build step runs on every leg unless SignPath signs the Windows one', () => {
+ // SignPath signs after the build, so on that lane tauri-action must not
+ // publish the unsigned installers and the updater signatures over them.
+ // With the detection skipped (Linux) or answering false, the condition is
+ // true and the step is the one that always ran.
+ const step = stepBlock(build, 'Build and release Tauri app')
+ expect(withoutComments(step)).toMatch(
+ /^\s*if: matrix\.platform != 'windows-latest' \|\| steps\.signcfg\.outputs\.signpath != 'true'\s*$/m,
+ )
+ })
+
+ it('a release never accepts the self-signed test certificate', () => {
+ const sign = withoutComments(stepBlock(build, 'Build and sign the Windows installers (SignPath)'))
+ expect(sign).not.toContain('allow-test-certificate')
+ expect(sign).toMatch(/expected-publisher: \$\{\{ vars\.SIGNPATH_EXPECTED_PUBLISHER \|\| 'SignPath Foundation' \}\}/)
+ const action = read('.github/actions/windows-signpath/action.yml')
+ expect(action).toMatch(/allow-test-certificate:\n(?:.*\n)*?\s+default: 'false'/)
+ })
+
+ it('the job keeps its 90 minutes unless the SignPath lane has to wait for an approval', () => {
+ expect(withoutComments(build)).toMatch(
+ /^\s{4}timeout-minutes: \$\{\{ matrix\.platform == 'windows-latest' && vars\.SIGNPATH_SIGNING_POLICY_SLUG != '' && 360 \|\| 90 \}\}\s*$/m,
+ )
+ })
+
+ it('and then the build gets the arguments it always got', () => {
+ // A skipped step has no outputs, so the trailing expression is empty and
+ // the only --config left is the updater overlay.
+ const step = stepBlock(build, 'Build and release Tauri app')
+ expect(withoutComments(step)).toMatch(
+ /^\s*args: --config src-tauri\/tauri\.release\.conf\.json \$\{\{ matrix\.args \}\} \$\{\{ steps\.winsign\.outputs\.config_args \}\}\s*$/m,
+ )
+ expect(read('scripts/windows-signing-setup.ps1')).toContain('"config_args=--config $overlayRel"')
+ })
+
+ it('no checked-in config carries a sign command or a certificate', () => {
+ for (const f of ['tauri.conf.json', 'tauri.windows.conf.json', 'tauri.release.conf.json']) {
+ const windows = JSON.parse(read(`src-tauri/${f}`)).bundle?.windows ?? {}
+ expect(windows.signCommand, f).toBeUndefined()
+ expect(windows.certificateThumbprint, f).toBeUndefined()
+ }
+ // The overlay is written at build time and must never be committed.
+ expect(read('.gitignore')).toMatch(/^src-tauri\/tauri\.signing\.conf\.json$/m)
+ })
+
+ it('the checked-in macOS identity stays ad hoc, the real one comes from the environment', () => {
+ // "-" is what makes a local build carry a verifiable signature so macOS
+ // keeps its permission answers (2e125131). A team's identity in this file
+ // would break every build that does not own that certificate.
+ // APPLE_SIGNING_IDENTITY overrides it in the release job.
+ expect(JSON.parse(read('src-tauri/tauri.conf.json')).bundle.macOS.signingIdentity).toBe('-')
+ })
+
+ it('the SignPath action signs the binary before the installers, and the updater files last', () => {
+ const action = read('.github/actions/windows-signpath/action.yml')
+ const order = [
+ 'npx tauri build --no-bundle',
+ 'windows-signpath.mjs stage-app',
+ 'id: sign-app',
+ 'npx tauri bundle --bundles "$kind"',
+ 'windows-signpath.mjs stage-installers',
+ 'id: sign-installers',
+ 'windows-signpath.mjs updater-artifacts',
+ 'npx tauri signer sign',
+ './scripts/windows-signing-verify.ps1',
+ ].map((needle) => ({ needle, at: action.indexOf(needle) }))
+ for (const { needle, at } of order) expect(at, needle).toBeGreaterThan(0)
+ expect(order.map((o) => o.at)).toEqual([...order.map((o) => o.at)].sort((a, b) => a - b))
+ // Third party actions by commit, like everywhere else in the workflows.
+ for (const uses of action.match(/^\s*uses: .*$/gm) ?? []) {
+ expect(uses, uses).toMatch(/@[0-9a-f]{40} # v\d/)
+ }
+ expect(withoutComments(action)).not.toMatch(/continue-on-error/)
+ })
+
+ it('the artifact configurations sign this project\'s own files and nothing else', () => {
+ const app = read('.signpath/artifact-configurations/windows-app.xml')
+ const installers = read('.signpath/artifact-configurations/windows-installers.xml')
+ // The binary name is the cargo package name, which is what the script stages.
+ const cargoName = /^name = "([^"]+)"/m.exec(read('src-tauri/Cargo.toml'))?.[1]
+ expect(app.match(/<pe-file path="([^"]+)"/g)).toEqual([`<pe-file path="${cargoName}.exe"`, `<pe-file path="${cargoName}.exe"`])
+ // The product name Windows builds carry, enforced as SignPath asks.
+ const productName = JSON.parse(read('src-tauri/tauri.windows.conf.json')).productName
+ for (const xml of [app, installers]) {
+ expect(xml).toContain(`product-name="${productName}" product-version="\${version}"`)
+ expect(xml).not.toMatch(/path="[^"]*(\*\*|llama|ggml)/)
+ }
+ expect(installers).toContain(`path="${productName}_\${version}_x64-setup.exe"`)
+ expect(installers).toContain(`path="${productName}_\${version}_x64_en-US.msi"`)
+ })
+
+ it('the probe workflow publishes nothing and never uses the release updater key', () => {
+ const probe = withoutComments(read('.github/workflows/signpath-probe.yml'))
+ expect(probe).toMatch(/^on:\n\s+workflow_dispatch:/m)
+ expect(probe).not.toMatch(/^\s+(release|push|pull_request|schedule):/m)
+ expect(probe).toMatch(/^permissions:\n\s+contents: read\n\s+actions: read$/m)
+ for (const forbidden of ['TAURI_SIGNING_PRIVATE_KEY', 'gh release', 'tauri-action', 'latest.json', 'GITHUB_TOKEN']) {
+ expect(probe, forbidden).not.toContain(forbidden)
+ }
+ expect(probe).toContain('uses: ./.github/actions/windows-signpath')
+ })
+
+ it('the release stays out of Latest until every build job is through', () => {
+ expect(jobBlock(RELEASE_YML, 'enforce-prerelease')).toMatch(/^\s*needs:\s*\[build-tauri, build-macos\]\s*$/m)
+ })
+})
diff --git a/src/lib/__tests__/windows-signpath.test.ts b/src/lib/__tests__/windows-signpath.test.ts
new file mode 100644
index 00000000..62d7eb0c
--- /dev/null
+++ b/src/lib/__tests__/windows-signpath.test.ts
@@ -0,0 +1,279 @@
+/**
+ * The file handling of the SignPath signing lane, executed.
+ *
+ * SignPath signs after the build, Tauri expects to sign during it. Everything
+ * in between that is plain file work lives in scripts/windows-signpath.mjs so
+ * that it can run here, on any system, without Windows and without a SignPath
+ * account. Signing itself is stood in for by `fakeSign`, which does to a PE
+ * file what a signature does as far as this script can tell: it fills the
+ * certificate table entry and appends bytes.
+ *
+ * VERIFICATION LIMIT, stated on purpose: no real signature is made or checked
+ * here. That SignPath accepts the two artifact configurations, that the
+ * bundler on Windows leaves a signed binary alone, and that the result
+ * verifies, is first proven by a run of .github/workflows/signpath-probe.yml.
+ *
+ * Run: npx vitest run src/lib/__tests__/windows-signpath.test.ts
+ */
+import { describe, it, expect, beforeEach, afterEach } from 'vitest'
+import { execFileSync } from 'node:child_process'
+import {
+ cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync,
+} from 'node:fs'
+import { tmpdir } from 'node:os'
+import { fileURLToPath } from 'node:url'
+import { dirname, join, resolve } from 'node:path'
+import { crc32 } from 'node:zlib'
+import {
+ VARIANTS, bundleTypeOf, mergeLatestJson, patchBundleType, peCertificateTableSize, releaseAssetName,
+ windowsPlatforms, zipOfOneFile,
+} from '../../../scripts/windows-signpath.mjs'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const root = resolve(here, '../../..')
+const SCRIPT = resolve(root, 'scripts/windows-signpath.mjs')
+
+const CERT_ENTRY = 0x40 + 24 + 112 + 4 * 8
+
+/** The smallest thing peCertificateTableSize accepts: a PE32+ header, then a body. */
+function fakeExe(body: string): Buffer {
+ const header = Buffer.alloc(0x40 + 24 + 112 + 16 * 8)
+ header.write('MZ', 0, 'latin1')
+ header.writeUInt32LE(0x40, 0x3c)
+ header.write('PE\0\0', 0x40, 'latin1')
+ header.writeUInt16LE(0x20b, 0x40 + 24)
+ return Buffer.concat([header, Buffer.from(body, 'latin1')])
+}
+
+function fakeSign(binary: Buffer): Buffer {
+ const signed = Buffer.concat([binary, Buffer.from('FAKE-AUTHENTICODE-SIGNATURE')])
+ signed.writeUInt32LE(binary.length, CERT_ENTRY)
+ signed.writeUInt32LE(27, CERT_ENTRY + 4)
+ return signed
+}
+
+const UNPATCHED = fakeExe('code before __TAURI_BUNDLE_TYPE_VAR_UNK code after')
+
+describe('the installer type marker', () => {
+ it('is written the way the bundler writes it: same length, same place, nothing else changes', () => {
+ for (const [variant, value] of Object.entries(VARIANTS)) {
+ const patched = patchBundleType(UNPATCHED, variant)
+ expect(patched.length).toBe(UNPATCHED.length)
+ expect(patched.toString('latin1')).toBe(UNPATCHED.toString('latin1').replace('__TAURI_BUNDLE_TYPE_VAR_UNK', value))
+ expect(bundleTypeOf(patched)).toBe(variant)
+ }
+ expect(bundleTypeOf(UNPATCHED)).toBeNull()
+ })
+
+ it('does not modify the buffer it was given', () => {
+ const before = Buffer.from(UNPATCHED)
+ patchBundleType(UNPATCHED, 'nsis')
+ expect(UNPATCHED.equals(before)).toBe(true)
+ })
+
+ it('refuses a binary that has no marker left, and an installer type it does not know', () => {
+ expect(() => patchBundleType(patchBundleType(UNPATCHED, 'msi'), 'nsis')).toThrow(/no __TAURI_BUNDLE_TYPE_VAR_UNK marker/)
+ expect(() => patchBundleType(UNPATCHED, 'appimage')).toThrow(/unknown installer type/)
+ })
+})
+
+describe('the certificate table of a PE file', () => {
+ it('is empty on an unsigned file and filled on a signed one', () => {
+ expect(peCertificateTableSize(UNPATCHED)).toBe(0)
+ expect(peCertificateTableSize(fakeSign(UNPATCHED))).toBe(27)
+ })
+
+ it('is not read from something that is no PE file', () => {
+ expect(() => peCertificateTableSize(Buffer.from('#!/bin/sh\n'.padEnd(200)))).toThrow(/not a PE file/)
+ })
+})
+
+describe('the v1 updater archive', () => {
+ it('is a ZIP with the one file in it, stored, under its own name', () => {
+ const data = Buffer.from('installer bytes '.repeat(100))
+ const zip = zipOfOneFile('Locally Uncensored_3.0.5_x64-setup.exe', data)
+ // Local header, then the name, then the data unchanged.
+ expect(zip.readUInt32LE(0)).toBe(0x04034b50)
+ expect(zip.readUInt16LE(8)).toBe(0)
+ expect(zip.readUInt32LE(14)).toBe(crc32(data))
+ const nameLength = zip.readUInt16LE(26)
+ expect(zip.toString('utf8', 30, 30 + nameLength)).toBe('Locally Uncensored_3.0.5_x64-setup.exe')
+ expect(zip.subarray(30 + nameLength, 30 + nameLength + data.length).equals(data)).toBe(true)
+ // End record: one entry, and the central directory sits where it says.
+ const end = zip.length - 22
+ expect(zip.readUInt32LE(end)).toBe(0x06054b50)
+ expect(zip.readUInt16LE(end + 10)).toBe(1)
+ expect(zip.readUInt32LE(zip.readUInt32LE(end + 16))).toBe(0x02014b50)
+ })
+})
+
+describe('latest.json', () => {
+ const files = [
+ 'Locally.Uncensored_3.0.5_x64-setup.exe', 'Locally.Uncensored_3.0.5_x64-setup.nsis.zip',
+ 'Locally.Uncensored_3.0.5_x64_en-US.msi', 'Locally.Uncensored_3.0.5_x64_en-US.msi.zip',
+ ]
+ const base = 'https://github.com/PurpleDoubleD/locally-uncensored/releases/download/v3.0.5'
+ const platforms = windowsPlatforms(files, (f) => `sig-of-${f}`, `${base}/`)
+
+ it('gets the three Windows entries tauri-action wrote for v3.0.5', () => {
+ expect(platforms).toEqual({
+ 'windows-x86_64': { signature: `sig-of-${files[3]}`, url: `${base}/${files[3]}` },
+ 'windows-x86_64-msi': { signature: `sig-of-${files[2]}`, url: `${base}/${files[2]}` },
+ 'windows-x86_64-nsis': { signature: `sig-of-${files[0]}`, url: `${base}/${files[0]}` },
+ })
+ })
+
+ it('keeps every other platform and field of the file on the release', () => {
+ const existing = {
+ version: '3.0.5', notes: 'notes', pub_date: '2026-10-05T18:55:23.782Z',
+ platforms: {
+ 'linux-x86_64': { signature: 'linux', url: 'https://example.invalid/app.AppImage.tar.gz' },
+ 'windows-x86_64-nsis': { signature: 'unsigned-build', url: 'https://example.invalid/old.exe' },
+ },
+ }
+ const merged = mergeLatestJson(existing, platforms, { version: '3.0.5', notes: 'ignored', pubDate: 'ignored' })
+ expect(merged.version).toBe('3.0.5')
+ expect(merged.notes).toBe('notes')
+ expect(merged.pub_date).toBe('2026-10-05T18:55:23.782Z')
+ expect(merged.platforms?.['linux-x86_64']).toEqual(existing.platforms['linux-x86_64'])
+ expect(merged.platforms?.['windows-x86_64-nsis'].signature).toBe(`sig-of-${files[0]}`)
+ expect(existing.platforms['windows-x86_64-nsis'].signature).toBe('unsigned-build')
+ })
+
+ it('starts a file when the release has none yet', () => {
+ const merged = mergeLatestJson(null, platforms, { version: '3.0.5', notes: 'body', pubDate: '2026-10-09T00:00:00.000Z' })
+ expect(merged).toMatchObject({ version: '3.0.5', notes: 'body', pub_date: '2026-10-09T00:00:00.000Z' })
+ expect(Object.keys(merged.platforms ?? {})).toHaveLength(3)
+ })
+
+ it('refuses to write into the file of another version', () => {
+ expect(() => mergeLatestJson({ version: '3.0.4' }, platforms, { version: '3.0.5', notes: '', pubDate: '' })).toThrow(/3\.0\.4/)
+ })
+
+ it('refuses a set of files in which an installer is missing or doubled', () => {
+ expect(() => windowsPlatforms(files.slice(0, 2), () => '', base)).toThrow(/zipped MSI/)
+ expect(() => windowsPlatforms([...files, 'Other_3.0.5_x64-setup.exe'], () => '', base)).toThrow(/NSIS installer/)
+ })
+
+ it('asset names are the ones GitHub would make of them', () => {
+ expect(releaseAssetName('Locally Uncensored_3.0.5_x64-setup.exe')).toBe('Locally.Uncensored_3.0.5_x64-setup.exe')
+ })
+})
+
+// The commands, run as the action runs them, in a copy of the script that
+// sits in a made-up repository: the script finds its tree relative to itself.
+describe('the commands, executed in order', () => {
+ let repo = ''
+ const run = (...args: string[]) =>
+ execFileSync(process.execPath, [join(repo, 'scripts/windows-signpath.mjs'), ...args], {
+ encoding: 'utf8', env: { PATH: process.env.PATH ?? '' }, stdio: ['ignore', 'pipe', 'pipe'],
+ })
+ const built = () => join(repo, 'src-tauri/target/release/probe-app.exe')
+
+ beforeEach(() => {
+ repo = mkdtempSync(join(tmpdir(), 'windows-signpath-'))
+ mkdirSync(join(repo, 'scripts'))
+ cpSync(SCRIPT, join(repo, 'scripts/windows-signpath.mjs'))
+ mkdirSync(join(repo, 'src-tauri/target/release'), { recursive: true })
+ writeFileSync(join(repo, 'src-tauri/Cargo.toml'), '[package]\nname = "probe-app"\nversion = "1.2.3"\n\n[dependencies]\nname = "decoy"\n')
+ writeFileSync(join(repo, 'src-tauri/tauri.conf.json'), JSON.stringify({ version: '1.2.3' }))
+ writeFileSync(built(), UNPATCHED)
+ })
+ afterEach(() => rmSync(repo, { recursive: true, force: true }))
+
+ /** What SignPath hands back for the first request: the same tree, signed. */
+ function signApp(unsigned: string, signed: string) {
+ for (const variant of ['nsis', 'msi']) {
+ mkdirSync(join(signed, variant), { recursive: true })
+ writeFileSync(join(signed, variant, 'probe-app.exe'), fakeSign(readFileSync(join(unsigned, variant, 'probe-app.exe'))))
+ }
+ }
+
+ it('stage-app writes one marked copy per installer type and reports the version', () => {
+ const out = join(repo, 'staged')
+ const log = run('stage-app', out)
+ expect(log).toContain('version=1.2.3')
+ expect(log).toContain('binary=probe-app.exe')
+ expect(readdirSync(out).sort()).toEqual(['msi', 'nsis'])
+ expect(bundleTypeOf(readFileSync(join(out, 'nsis/probe-app.exe')))).toBe('nsis')
+ expect(bundleTypeOf(readFileSync(join(out, 'msi/probe-app.exe')))).toBe('msi')
+ // The build itself stays as cargo left it.
+ expect(readFileSync(built()).equals(UNPATCHED)).toBe(true)
+ })
+
+ it('stage-app refuses a build that is signed already', () => {
+ writeFileSync(built(), fakeSign(UNPATCHED))
+ expect(() => run('stage-app', join(repo, 'staged'))).toThrow(/already signed/)
+ })
+
+ it('place-app puts the signed copy where the bundler looks, check-app notices a changed file', () => {
+ const unsigned = join(repo, 'staged')
+ const signed = join(repo, 'signed')
+ run('stage-app', unsigned)
+ signApp(unsigned, signed)
+ run('place-app', 'nsis', signed)
+ expect(readFileSync(built()).equals(readFileSync(join(signed, 'nsis/probe-app.exe')))).toBe(true)
+ run('check-app', 'nsis', signed)
+ // A bundler that wrote into the binary would leave a different file.
+ writeFileSync(built(), Buffer.concat([readFileSync(built()), Buffer.from('x')]))
+ expect(() => run('check-app', 'nsis', signed)).toThrow(/signature no longer covers/)
+ })
+
+ it('place-app refuses what came back unsigned, and a copy marked for the other installer', () => {
+ const unsigned = join(repo, 'staged')
+ run('stage-app', unsigned)
+ expect(() => run('place-app', 'nsis', unsigned)).toThrow(/without a signature/)
+ const swapped = join(repo, 'swapped')
+ mkdirSync(join(swapped, 'nsis'), { recursive: true })
+ writeFileSync(join(swapped, 'nsis/probe-app.exe'), fakeSign(readFileSync(join(unsigned, 'msi/probe-app.exe'))))
+ expect(() => run('place-app', 'nsis', swapped)).toThrow(/not marked for the nsis installer/)
+ })
+
+ it('stage-installers takes exactly the two installers, updater-artifacts names them for the release', () => {
+ const bundle = join(repo, 'src-tauri/target/release/bundle')
+ mkdirSync(join(bundle, 'nsis'), { recursive: true })
+ mkdirSync(join(bundle, 'msi'), { recursive: true })
+ writeFileSync(join(bundle, 'nsis/Probe App_1.2.3_x64-setup.exe'), fakeExe('nsis installer'))
+ writeFileSync(join(bundle, 'msi/Probe App_1.2.3_x64_en-US.msi'), 'msi installer')
+ const staged = join(repo, 'installers')
+ run('stage-installers', staged)
+ expect(readdirSync(staged).sort()).toEqual(['Probe App_1.2.3_x64-setup.exe', 'Probe App_1.2.3_x64_en-US.msi'])
+
+ // Unsigned installers must not become updater files.
+ const dist = join(repo, 'dist')
+ expect(() => run('updater-artifacts', staged, dist)).toThrow(/without a signature/)
+
+ const setup = join(staged, 'Probe App_1.2.3_x64-setup.exe')
+ writeFileSync(setup, fakeSign(readFileSync(setup)))
+ run('updater-artifacts', staged, dist)
+ expect(readdirSync(dist).sort()).toEqual([
+ 'Probe.App_1.2.3_x64-setup.exe', 'Probe.App_1.2.3_x64-setup.nsis.zip',
+ 'Probe.App_1.2.3_x64_en-US.msi', 'Probe.App_1.2.3_x64_en-US.msi.zip',
+ ])
+ expect(readFileSync(join(dist, 'Probe.App_1.2.3_x64-setup.exe')).equals(readFileSync(setup))).toBe(true)
+
+ // merge-latest-json wants a signature next to every file it names.
+ const latest = join(repo, 'latest.json')
+ expect(() => run('merge-latest-json', dist, latest, 'https://example.invalid/dl')).toThrow(/no updater signature/)
+ for (const file of readdirSync(dist)) writeFileSync(join(dist, `${file}.sig`), `sig-of-${file}\n`)
+ writeFileSync(latest, JSON.stringify({ version: '1.2.3', platforms: { 'linux-x86_64': { signature: 'l', url: 'u' } } }))
+ run('merge-latest-json', dist, latest, 'https://example.invalid/dl')
+ const written = JSON.parse(readFileSync(latest, 'utf8'))
+ expect(Object.keys(written.platforms).sort()).toEqual(['linux-x86_64', 'windows-x86_64', 'windows-x86_64-msi', 'windows-x86_64-nsis'])
+ expect(written.platforms['windows-x86_64-nsis']).toEqual({
+ signature: 'sig-of-Probe.App_1.2.3_x64-setup.exe',
+ url: 'https://example.invalid/dl/Probe.App_1.2.3_x64-setup.exe',
+ })
+ })
+
+ it('stage-installers refuses a bundle directory with a second installer in it', () => {
+ const bundle = join(repo, 'src-tauri/target/release/bundle')
+ mkdirSync(join(bundle, 'nsis'), { recursive: true })
+ mkdirSync(join(bundle, 'msi'), { recursive: true })
+ writeFileSync(join(bundle, 'nsis/A_1.2.3_x64-setup.exe'), 'a')
+ writeFileSync(join(bundle, 'nsis/B_1.2.2_x64-setup.exe'), 'b')
+ writeFileSync(join(bundle, 'msi/A_1.2.3_x64_en-US.msi'), 'm')
+ expect(() => run('stage-installers', join(repo, 'installers'))).toThrow(/exactly one NSIS installer/)
+ expect(existsSync(join(repo, 'installers'))).toBe(false)
+ })
+})