Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
build: package and release Cap and Cap Classic as separate apps
Cursor Agent125f8fbd1071
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex a0c5dba14..b6b2f9f0e 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -46,11 +46,13 @@ jobs:- 'packages/web-api-contract/**'- 'scripts/build-desktop-binaries*'- 'scripts/build-gpui-binary.sh'+ - 'scripts/build-linux-packages.mjs'- 'scripts/build-macos-packages*'+ - 'scripts/bundle-gpui*'+ - 'scripts/finalize-linux-*'+ - 'scripts/linux-bundle-config*'- 'scripts/prepare-gpui-dependency*'- - 'scripts/run-gpui-build*'- 'scripts/sync-desktop-versions.mjs'- - 'scripts/verify-gpui-release-inputs.mjs'- 'Cargo.toml'- 'Cargo.lock'- 'bun.lock'@@ -270,7 +272,7 @@ jobs:uses: actions/checkout@v4- name: Test desktop build preparation- run: node --test scripts/prepare-gpui-dependency.test.mjs scripts/build-macos-packages.test.mjs+ run: node --test scripts/prepare-gpui-dependency.test.mjs scripts/build-macos-packages.test.mjs scripts/bundle-gpui.test.mjs- name: Install Linux desktop dependenciesif: ${{ runner.os == 'Linux' }}@@ -325,7 +327,7 @@ jobs:if: ${{ runner.os == 'Linux' }}shell: bashrun: |- node --test scripts/linux-bundle-config.test.mjs scripts/finalize-linux-appimage.test.mjs+ node --test scripts/linux-bundle-config.test.mjs scripts/finalize-linux-appimage.test.mjs scripts/finalize-linux-gpui-packages.test.mjsbun run --cwd apps/desktop vitest run scripts/prepare.test.jscargo test --locked -p cap-utils -p cap-cli-install --libcargo test --locked -p cap --bin cap record::testsdiff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.ymlindex 6c5a62af5..46802059b 100644--- a/.github/workflows/desktop-release.yml+++ b/.github/workflows/desktop-release.yml@@ -5,6 +5,10 @@ name: "desktop-release"# - publish-nightly.yml -> channel: nightly, generated prerelease version, auto CN publish# - promote-nightly.yml -> channel: stable, rebuilds a nightly's commit as a plain x.y.z#+# Every release carries two apps from one commit: Cap (the GPUI app) under the+# platform names existing installs update from, and Cap Classic (the Tauri+# app) under `-classic` platform names, so neither ever updates into the other.+## Stable releases get a cap-v{version} git tag + draft GitHub release and are# published on CrabNebula manually (Discord bot / dashboard), exactly as before.# Nightly releases skip the GitHub side entirely and go to the CrabNebula@@ -201,16 +205,25 @@ jobs:settings:- target: x86_64-apple-darwinrunner: macos-latest-xlarge+ arch: x86_64- target: aarch64-apple-darwinrunner: macos-latest-xlarge+ arch: aarch64- target: x86_64-pc-windows-msvcrunner: windows-2022+ arch: x86_64- target: x86_64-unknown-linux-gnurunner: ubuntu-24.04+ arch: x86_64env:TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}TURBO_TEAM: ${{ secrets.TURBO_TEAM }}CN_CHANNEL_FLAG: ${{ inputs.channel == 'nightly' && '--channel nightly' || '' }}+ # Cap is the GPUI app and keeps the platform names every existing+ # install updates from; Cap Classic is the Tauri app, built from the+ # same commit and published beside it under `-classic` platforms.+ CAP_BUNDLE: apps/desktop-gpui/target/${{ matrix.settings.target }}/release/bundle+ CLASSIC_BUNDLE: target/${{ matrix.settings.target }}/release/bundleruns-on: ${{ matrix.settings.runner }}steps:- name: Checkout repository@@ -222,9 +235,8 @@ jobs:if: ${{ hashFiles('scripts/prepare-gpui-dependency.test.mjs') != '' }}run: node --test scripts/prepare-gpui-dependency.test.mjs- - name: Test macOS packaging retries- if: ${{ hashFiles('scripts/build-macos-packages.test.mjs') != '' }}- run: node --test scripts/build-macos-packages.test.mjs+ - name: Test desktop packaging scripts+ run: node --test scripts/build-macos-packages.test.mjs scripts/bundle-gpui.test.mjs- name: Install Linux desktop dependenciesif: ${{ runner.os == 'Linux' }}@@ -271,7 +283,8 @@ jobs:apps/desktop-gpui -> target# Nightly and promoted builds carry a version that differs from the- # committed Cargo.toml; Tauri reads the app version from package.version.+ # committed Cargo.toml; Tauri reads the app version from package.version,+ # and the GPUI build syncs its own manifest from this one.# Runs after the cache step so the stamped version never lands in the# cache key's Cargo.toml hash (a fresh nightly version each night would# otherwise write a fresh multi-GB cache entry per target per night).@@ -294,6 +307,7 @@ jobs:fs.writeFileSync(path, toml);console.log("Stamped " + path + " with " + version);'+ node scripts/sync-desktop-versions.mjs- uses: ./.github/actions/setup-js@@ -360,10 +374,23 @@ jobs:maximum-size: 24GBdisk-root: "D:"- - name: Build app+ - name: Build Cap Classicworking-directory: apps/desktop- run: ${{ runner.os == 'Linux' && 'CARGO_PROFILE_RELEASE_DEBUG=0 node ../../scripts/build-linux-packages.mjs' || runner.os == 'macOS' && hashFiles('scripts/build-macos-packages.mjs') != '' && 'node ../../scripts/build-macos-packages.mjs' || 'bun run build:tauri --target' }} ${{ matrix.settings.target }} --config src-tauri/tauri.prod.conf.json ${{ runner.os == 'Windows' && '--bundles nsis' || runner.os == 'Linux' && '--verbose' || '' }}+ shell: bash+ run: |+ case "$RUNNER_OS" in+ Linux)+ CARGO_PROFILE_RELEASE_DEBUG=0 node ../../scripts/build-linux-packages.mjs "$TARGET" classic --config src-tauri/tauri.prod.conf.json --verbose+ ;;+ macOS)+ node ../../scripts/build-macos-packages.mjs "$TARGET" --config src-tauri/tauri.prod.conf.json+ ;;+ Windows)+ bun run build:tauri --target "$TARGET" --config src-tauri/tauri.prod.conf.json --bundles nsis+ ;;+ esacenv:+ TARGET: ${{ matrix.settings.target }}# https://github.com/tauri-apps/tauri-action/issues/740CI: falseLD_LIBRARY_PATH: ${{ runner.os == 'Linux' && format('{0}/target/{1}/release:{0}/target/native-deps/lib', github.workspace, matrix.settings.target) || '' }}@@ -381,8 +408,41 @@ jobs:TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}RUST_TARGET_TRIPLE: ${{ matrix.settings.target }}- # Tauri patches Cap.exe with the NSIS marker during the first bundle.- # Sign those patched bytes, then rebundle with the same package type.+ # The Tauri bundler is only the packager here: it lays the prebuilt GPUI+ # binary out in the same app bundle, installer and package formats the+ # Tauri updater already installs, so existing installs update into Cap.+ - name: Build Cap+ shell: bash+ run: |+ case "$RUNNER_OS" in+ Linux)+ CARGO_PROFILE_RELEASE_DEBUG=0 node scripts/build-linux-packages.mjs "$TARGET" cap --verbose+ ;;+ macOS)+ node scripts/bundle-gpui.mjs "$TARGET" --bundles app,dmg+ ;;+ Windows)+ node scripts/bundle-gpui.mjs "$TARGET" --no-bundle+ ;;+ esac+ env:+ TARGET: ${{ matrix.settings.target }}+ CI: false+ LD_LIBRARY_PATH: ${{ runner.os == 'Linux' && format('{0}/apps/desktop-gpui/target/{1}/release:{0}/target/native-deps/lib', github.workspace, matrix.settings.target) || '' }}+ APPLE_CERTIFICATE: ${{ runner.os == 'macOS' && secrets.APPLE_CERTIFICATE || '' }}+ APPLE_CERTIFICATE_PASSWORD: ${{ runner.os == 'macOS' && secrets.APPLE_CERTIFICATE_PASSWORD || '' }}+ APPLE_SIGNING_IDENTITY: ${{ runner.os == 'macOS' && secrets.APPLE_SIGNING_IDENTITY || '' }}+ APPLE_API_ISSUER: ${{ runner.os == 'macOS' && secrets.APPLE_API_ISSUER || '' }}+ APPLE_API_KEY: ${{ runner.os == 'macOS' && secrets.APPLE_API_KEY || '' }}+ APPLE_API_KEY_PATH: ${{ runner.os == 'macOS' && format('{0}/api.p8', github.workspace) || '' }}+ APPLE_KEYCHAIN: ${{ runner.os == 'macOS' && format('{0}/build.keychain', runner.temp) || '' }}+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}+ RUST_TARGET_TRIPLE: ${{ matrix.settings.target }}++ # Tauri patches Cap Classic.exe with the NSIS marker during the first+ # bundle. Sign those patched bytes and Cap's prebuilt binary in one+ # request, then bundle both installers from the signed payload.- name: Stage Windows payload for Authenticode signingif: ${{ runner.os == 'Windows' }}shell: pwsh@@ -421,12 +481,14 @@ jobs:run: |./scripts/windows-release-signing.ps1 -Operation Restore -Target "${{ matrix.settings.target }}" -WorkspaceRoot "$env:GITHUB_WORKSPACE"- - name: Bundle Windows installer+ - name: Bundle Windows installersif: ${{ runner.os == 'Windows' }}- working-directory: apps/desktopshell: bash- run: bun run tauri bundle --target ${{ matrix.settings.target }} --bundles nsis --config src-tauri/tauri.prod.conf.json+ run: |+ (cd apps/desktop && bun run tauri bundle --target "$TARGET" --bundles nsis --config src-tauri/tauri.prod.conf.json)+ node scripts/bundle-gpui.mjs "$TARGET" --skip-build --bundles nsisenv:+ TARGET: ${{ matrix.settings.target }}TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}@@ -435,41 +497,65 @@ jobs:shell: bashrun: |set -euo pipefail- APP="target/${{ matrix.settings.target }}/release/bundle/macos/Cap.app"- for binary in Cap cap-muxer cap-exporter cap-cli cap-gpui; do- executable="$APP/Contents/MacOS/$binary"- if [[ ! -x "$executable" ]]; then- echo "::error::Bundled executable missing or not executable: $executable"+ verify_app() {+ local app="$1" executable_name="$2"+ shift 2+ local plist="$app/Contents/Info.plist"+ if [[ "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$plist")" != "so.cap.desktop" ]]; then+ echo "::error::$app does not keep the so.cap.desktop identity."exit 1fi- codesign --verify --strict "$executable"- done- GPUI_SIGNATURE="$(codesign -dv --verbose=4 "$APP/Contents/MacOS/cap-gpui" 2>&1)"- if ! grep -Eq 'flags=.*runtime' <<< "$GPUI_SIGNATURE"; then- echo "::error::Cap GPUI is not signed with the macOS hardened runtime."- exit 1- fi- if ! grep -Eq '^Authority=Developer ID Application:' <<< "$GPUI_SIGNATURE"; then- echo "::error::Cap GPUI is not signed with a Developer ID Application certificate."- exit 1- fi- codesign --verify --deep --strict "$APP"- spctl --assess --type execute "$APP"- xcrun stapler validate "$APP"- if [[ ! -s "$APP.tar.gz" || ! -s "$APP.tar.gz.sig" ]]; then- echo "::error::macOS updater artifact or production signature is missing."- exit 1- fi- DMG="$(find "target/${{ matrix.settings.target }}/release/bundle/dmg" -maxdepth 1 -type f -name '*.dmg' -print -quit)"- if [[ -z "$DMG" || ! -s "$DMG" ]]; then- echo "::error::macOS disk image is missing or empty."+ if [[ "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$plist")" != "$executable_name" ]]; then+ echo "::error::$app does not launch $executable_name."+ exit 1+ fi+ for binary in "$executable_name" "$@"; do+ executable="$app/Contents/MacOS/$binary"+ if [[ ! -x "$executable" ]]; then+ echo "::error::Bundled executable missing or not executable: $executable"+ exit 1+ fi+ codesign --verify --strict "$executable"+ done+ if [[ -e "$app/Contents/MacOS/cap-gpui" ]]; then+ echo "::error::$app still bundles the GPUI sidecar."+ exit 1+ fi+ SIGNATURE="$(codesign -dv --verbose=4 "$app/Contents/MacOS/$executable_name" 2>&1)"+ if ! grep -Eq 'flags=.*runtime' <<< "$SIGNATURE"; then+ echo "::error::$executable_name is not signed with the macOS hardened runtime."+ exit 1+ fi+ if ! grep -Eq '^Authority=Developer ID Application:' <<< "$SIGNATURE"; then+ echo "::error::$executable_name is not signed with a Developer ID Application certificate."+ exit 1+ fi+ codesign --verify --deep --strict "$app"+ spctl --assess --type execute "$app"+ xcrun stapler validate "$app"+ if [[ ! -s "$app.tar.gz" || ! -s "$app.tar.gz.sig" ]]; then+ echo "::error::The $app updater artifact or production signature is missing."+ exit 1+ fi+ local bundle_root dmg+ bundle_root="$(dirname "$(dirname "$app")")"+ dmg="$(find "$bundle_root/dmg" -maxdepth 1 -type f -name '*.dmg' -print -quit)"+ if [[ -z "$dmg" || ! -s "$dmg" ]]; then+ echo "::error::The disk image beside $app is missing or empty."+ exit 1+ fi+ codesign --verify "$dmg"+ }+ verify_app "$CAP_BUNDLE/macos/Cap.app" Cap cap-muxer cap-cli+ if [[ -e "$CAP_BUNDLE/macos/Cap.app/Contents/MacOS/cap-exporter" ]]; then+ echo "::error::Cap still bundles the duplicate cap-exporter sidecar."exit 1fi- codesign --verify "$DMG"+ verify_app "$CLASSIC_BUNDLE/macos/Cap Classic.app" "Cap Classic" cap-muxer cap-exporter cap-cli- - name: Notarize and verify macOS disk image+ - name: Notarize and verify macOS disk imagesif: ${{ runner.os == 'macOS' }}- timeout-minutes: 25+ timeout-minutes: 45shell: bashenv:APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}@@ -478,9 +564,9 @@ jobs:run: |set -euo pipefailshopt -s nullglob- DMGS=(target/${{ matrix.settings.target }}/release/bundle/dmg/*.dmg)- if [[ ${#DMGS[@]} -eq 0 ]]; then- echo "::error::No macOS disk image is available for notarization."+ DMGS=("$CAP_BUNDLE"/dmg/*.dmg "$CLASSIC_BUNDLE"/dmg/*.dmg)+ if [[ ${#DMGS[@]} -ne 2 ]]; then+ echo "::error::Expected the Cap and Cap Classic disk images, found ${#DMGS[@]}."exit 1fi[[ -n "$APPLE_API_KEY" && -n "$APPLE_API_ISSUER" && -s "$APPLE_API_KEY_PATH" ]]@@ -511,17 +597,16 @@ jobs:# Guards against the Linux packaging regressions:# 1. Frontend missing: vinxi must produce apps/desktop/.output/public,- # which Tauri EMBEDS into the binary (it is NOT shipped as a loose- # /usr/lib/Cap/index.html file). A blank webview ships if turbo's cache- # restores an empty .output/public (see @cap/desktop#build outputs in- # turbo.json), so we assert the build output exists and is non-empty.- # 2. FFmpeg soname mismatch: every libav*/libsw* the main binary lists as+ # which Tauri EMBEDS into Cap Classic. A blank webview ships if+ # turbo's cache restores an empty .output/public (see+ # @cap/desktop#build outputs in turbo.json).+ # 2. FFmpeg soname mismatch: every libav*/libsw* a binary lists as# NEEDED must be bundled under /usr/lib/cap/ with the exact same soname.- # The bundled libs come from native-deps (FFmpeg 7); if the binary+ # The bundled libs come from native-deps (FFmpeg 7); if a binary# linked system FFmpeg 6 the loader fails at launch.- # 3. Undeclared runtime dependency: a system lib the binary NEEDs that is- # neither bundled nor part of the declared GTK/webkit stack must appear- # in the .deb Depends, or the loader aborts at launch. This is the+ # 3. Undeclared runtime dependency: a system lib a binary NEEDs that is+ # neither bundled nor part of the declared stack must appear in the+ # .deb Depends, or the loader aborts at launch. This is the# libpipewire-0.3.so.0 crash that shipped in 0.5.2.- name: Verify Linux deb contentsif: ${{ runner.os == 'Linux' }}@@ -529,25 +614,19 @@ jobs:run: |set -euo pipefail- # (1) frontend was actually built. Tauri embeds .output/public into the- # binary at build time, so an empty/missing dir => blank webview.- FE="apps/desktop/.output/public/index.html"- if [[ ! -s "$FE" ]]; then- echo "::error::Frontend build output missing/empty ($FE) - webview would be blank."- ls -la apps/desktop/.output/public 2>/dev/null || echo "(no .output/public dir)"- exit 1- fi- echo "Frontend build output OK ($FE, $(wc -c < "$FE") bytes)"-- DEB="$(find target/${{ matrix.settings.target }}/release/bundle/deb -name '*.deb' | head -n1)"+ DEB="$(find "$CAP_BUNDLE/deb" -name '*.deb' | head -n1)"if [[ -z "$DEB" ]]; then echo "::error::No .deb produced"; exit 1; fiif [[ ! -s "$DEB.sig" ]]; then echo "::error::No .deb updater signature produced next to $DEB"; exit 1; fi+ if [[ "$(dpkg-deb -f "$DEB" Package)" != "cap" ]]; then+ echo "::error::The Cap deb must keep the 'cap' package name so existing installs upgrade into it."+ exit 1+ fiecho "Inspecting $DEB"WORK="$(mktemp -d)"dpkg-deb -x "$DEB" "$WORK"EXECUTABLES=()- for binary in Cap cap-muxer cap-exporter cap-cli cap-gpui; do+ for binary in Cap cap-muxer cap-cli; doexecutable="$WORK/usr/bin/$binary"if [[ ! -x "$executable" ]]; thenecho "::error::Bundled executable missing or not executable: /usr/bin/$binary"@@ -555,48 +634,48 @@ jobs:fiEXECUTABLES+=("$executable")done+ for binary in cap-gpui cap-exporter; do+ if [[ -e "$WORK/usr/bin/$binary" ]]; then+ echo "::error::The Cap deb still ships /usr/bin/$binary"+ exit 1+ fi+ done- GPUI_RPATH="$(objdump -p "$WORK/usr/bin/cap-gpui" | awk '/RPATH|RUNPATH/{print $2}')"- if [[ "$GPUI_RPATH" != *"\$ORIGIN/../lib/cap"* ]]; then- echo "::error::The bundled GPUI executable cannot resolve shared libraries from /usr/lib/cap"+ CAP_RPATH="$(objdump -p "$WORK/usr/bin/Cap" | awk '/RPATH|RUNPATH/{print $2}')"+ if [[ "$CAP_RPATH" != *"\$ORIGIN/../lib/cap"* ]]; then+ echo "::error::The bundled Cap executable cannot resolve shared libraries from /usr/lib/cap"exit 1fi- # Best-effort confirmation that the SPA actually got embedded into the- # binary (Tauri stores asset path keys as plaintext). Informational only.- if strings "$WORK/usr/bin/Cap" 2>/dev/null | grep -q "index.html"; then- echo "Binary appears to embed the frontend (index.html key present)"- else- echo "::warning::Could not confirm embedded frontend key in binary (asset format may differ)"- fi-- # (2) every FFmpeg soname the binary NEEDs is bundled+ # (2) every FFmpeg soname the binaries NEED is bundledNEEDED="$(for executable in "${EXECUTABLES[@]}"; do objdump -p "$executable"; done | awk '/NEEDED/{print $2}' | grep -E '^lib(av|sw|postproc)' | sort -u || true)"- echo "Binary NEEDs FFmpeg sonames:"; echo "${NEEDED:-(none)}"+ echo "Binaries NEED FFmpeg sonames:"; echo "${NEEDED:-(none)}"echo "Bundled FFmpeg libs:"; ls -1 "$WORK/usr/lib/cap" 2>/dev/null || trueMISSING=0for so in $NEEDED; doif [[ ! -f "$WORK/usr/lib/cap/$so" ]]; then- echo "::error::Binary NEEDs $so but it is not bundled under /usr/lib/cap/"+ echo "::error::A binary NEEDs $so but it is not bundled under /usr/lib/cap/"MISSING=1fidoneif [[ "$MISSING" -ne 0 ]]; then- echo "::error::FFmpeg soname mismatch between binary and bundled libs."+ echo "::error::FFmpeg soname mismatch between binaries and bundled libs."exit 1fiecho "FFmpeg soname bundle OK"- # (3) runtime libs that are NOT bundled and NOT pulled in by the- # declared GTK/webkit stack must be declared in the .deb Depends, or- # the dynamic loader aborts at launch (the libpipewire-0.3.so.0 crash- # in 0.5.2). Assert the curated set of such sonames the binary links.+ # (3) runtime libs that are NOT bundled must be declared in the .deb+ # Depends, or the dynamic loader aborts at launch.DEPENDS="$(dpkg-deb -f "$DEB" Depends || true)"echo "Declared Depends: ${DEPENDS:-(none)}"if ! echo "$DEPENDS" | grep -Eq '(^|,[[:space:]]*)pulseaudio-utils([[:space:](,]|$)'; thenecho "::error::Linux system audio requires pulseaudio-utils (pactl) in .deb Depends."exit 1fi+ if echo "$DEPENDS" | grep -Eq 'webkit2gtk|libgtk-3|appindicator'; then+ echo "::error::The Cap deb must not depend on the Tauri webview stack."+ exit 1+ fiNEEDED_ALL="$(for executable in "${EXECUTABLES[@]}"; do objdump -p "$executable"; done | awk '/NEEDED/{print $2}' | sort -u)"# soname -> a Depends token that satisfies it. The alsa token is a# substring so it matches both libasound2 and libasound2t64.@@ -605,6 +684,7 @@ jobs:[libasound.so.2]="libasound2"[libxkbcommon.so.0]="libxkbcommon0"[libxkbcommon-x11.so.0]="libxkbcommon-x11-0"+ [libX11.so.6]="libx11-6"[libssl.so.3]="libssl3")DEP_MISSING=0@@ -612,7 +692,7 @@ jobs:if echo "$NEEDED_ALL" | grep -qx "$so"; thentok="${SONAME_DEP[$so]}"if ! echo "$DEPENDS" | grep -q "$tok"; then- echo "::error::Binary NEEDs $so but '$tok' is not declared in .deb Depends (add it to tauri.conf.json bundle.linux.deb.depends)."+ echo "::error::A binary NEEDs $so but '$tok' is not declared in .deb Depends (add it to apps/desktop-gpui/tauri.conf.json bundle.linux.deb.depends)."DEP_MISSING=1elseecho "Runtime dep OK: $so -> $tok"@@ -632,43 +712,74 @@ jobs:CAP_RELEASE_VERSION: ${{ inputs.version }}run: |set -euo pipefail- BUNDLE="${{ github.workspace }}/target/${{ matrix.settings.target }}/release/bundle"- RPM="$BUNDLE/rpm/Cap-$CAP_RELEASE_VERSION-1.x86_64.rpm"- APPIMAGE="$BUNDLE/appimage/Cap_${CAP_RELEASE_VERSION}_amd64.AppImage"+ RPM="$CAP_BUNDLE/rpm/Cap-$CAP_RELEASE_VERSION-1.x86_64.rpm"+ APPIMAGE="$CAP_BUNDLE/appimage/Cap_${CAP_RELEASE_VERSION}_amd64.AppImage"+ CLASSIC_APPIMAGE="$CLASSIC_BUNDLE/appimage/Cap Classic_${CAP_RELEASE_VERSION}_amd64.AppImage"test -s "$APPIMAGE.sig"+ test -s "$CLASSIC_APPIMAGE.sig"WORK="$(mktemp -d)"trap 'rm -rf "$WORK"' EXIT- mkdir "$WORK/rpm" "$WORK/appimage"- (cd "$WORK/appimage" && "$APPIMAGE" --appimage-extract > /dev/null)+ mkdir "$WORK/rpm" "$WORK/appimage" "$WORK/classic"+ (cd "$WORK/appimage" && "$(realpath "$APPIMAGE")" --appimage-extract > /dev/null)+ (cd "$WORK/classic" && "$(realpath "$CLASSIC_APPIMAGE")" --appimage-extract > /dev/null)APPROOT="$WORK/appimage/squashfs-root"- ROOTS=("$APPROOT")+ CLASSIC_APPROOT="$WORK/classic/squashfs-root"+ verify_root() {+ local root="$1"+ shift+ for binary in "$@"; do+ test -x "$root/usr/bin/$binary"+ while read -r soname; do+ test -f "$root/usr/lib/cap/$soname"+ done < <(objdump -p "$root/usr/bin/$binary" | awk '/NEEDED/{print $2}' | grep -E '^lib(av|sw|postproc)' || true)+ done+ test ! -e "$root/usr/bin/cap-gpui"+ }+ verify_root "$APPROOT" Cap cap-muxer cap-cli+ verify_root "$CLASSIC_APPROOT" "Cap Classic" cap-muxer cap-exporter cap-cli+ if [[ -n "$(find "$APPROOT" \( -name 'libwebkit2gtk-*' -o -name 'libgtk-3.so*' -o -name 'WebKitWebProcess' \) -print -quit)" || -e "$APPROOT/apprun-hooks" ]]; then+ echo "::error::The Cap AppImage still bundles the Tauri webview runtime"+ exit 1+ fiif [[ "$CAP_RELEASE_VERSION" != *-* ]]; thentest -s "$RPM"test "$(rpm -qp --queryformat '%{VERSION}-%{RELEASE}' "$RPM")" = "$CAP_RELEASE_VERSION-1"rpm -Kv "$RPM"+ if rpm -qpR "$RPM" | grep -Eq 'webkit2gtk|libgtk-3|gtk3'; then+ echo "::error::The Cap RPM must not require the Tauri webview stack."+ exit 1+ fibsdtar -xf "$RPM" -C "$WORK/rpm"test "$(cat "$WORK/rpm/usr/lib/cap/package-format")" = rpm- ROOTS+=("$WORK/rpm")+ verify_root "$WORK/rpm" Cap cap-muxer cap-clifi- for ROOT in "${ROOTS[@]}"; do- for binary in Cap cap-muxer cap-exporter cap-cli cap-gpui; do- test -x "$ROOT/usr/bin/$binary"- while read -r soname; do- test -f "$ROOT/usr/lib/cap/$soname"- done < <(objdump -p "$ROOT/usr/bin/$binary" | awk '/NEEDED/{print $2}' | grep -E '^lib(av|sw|postproc)' || true)- done+ for root in "$APPROOT" "$CLASSIC_APPROOT"; do+ test "$(cat "$root/usr/lib/cap/package-format")" = appimage+ test -x "$root/usr/bin/pactl"+ test -s "$root/usr/lib/alsa-lib/libasound_module_pcm_pulse.so"+ test -s "$root/usr/lib/cap/alsa-pulse.conf"+ if [[ -n "$(find "$root" -name 'libwayland-client.so*' -print -quit)" ]]; then+ echo "::error::$root bundles a Wayland client that can conflict with host Mesa drivers"+ exit 1+ fi+ if [[ -n "$(find "$root/usr/lib" -maxdepth 1 -name 'libpipewire-0.3.so*' -print -quit)" ]]; then+ echo "::error::$root bundles PipeWire that can conflict with host ALSA plugins"+ exit 1+ fidone- test "$(cat "$APPROOT/usr/lib/cap/package-format")" = appimage- test -x "$APPROOT/usr/bin/pactl"- test -s "$APPROOT/usr/lib/alsa-lib/libasound_module_pcm_pulse.so"- test -s "$APPROOT/usr/lib/cap/alsa-pulse.conf"- if [[ -n "$(find "$APPROOT" -name 'libwayland-client.so*' -print -quit)" ]]; then- echo "::error::AppImage bundles a Wayland client that can conflict with host Mesa drivers"++ # Tauri embeds .output/public into Cap Classic, so an empty or+ # missing directory means a blank webview.+ FE="apps/desktop/.output/public/index.html"+ if [[ ! -s "$FE" ]]; then+ echo "::error::Frontend build output missing/empty ($FE) - Cap Classic's webview would be blank."+ ls -la apps/desktop/.output/public 2>/dev/null || echo "(no .output/public dir)"exit 1fi- if [[ -n "$(find "$APPROOT/usr/lib" -maxdepth 1 -name 'libpipewire-0.3.so*' -print -quit)" ]]; then- echo "::error::AppImage bundles PipeWire that can conflict with host ALSA plugins"- exit 1+ if strings "$CLASSIC_APPROOT/usr/bin/Cap Classic" 2>/dev/null | grep -q "index.html"; then+ echo "Cap Classic appears to embed the frontend (index.html key present)"+ else+ echo "::warning::Could not confirm the embedded frontend key in Cap Classic (asset format may differ)"fi- name: Build Arch Linux package@@ -677,55 +788,77 @@ jobs:shell: bashrun: |set -euo pipefail- BUNDLE="target/${{ matrix.settings.target }}/release/bundle"- mkdir -p "$BUNDLE/arch"+ mkdir -p "$CAP_BUNDLE/arch"docker run --rm --network none \--env CAP_PACKAGE_UID="$(id -u)" \--volume "${{ github.workspace }}:/source:ro" \- --volume "${{ github.workspace }}/$BUNDLE/arch:/output" \+ --volume "${{ github.workspace }}/$CAP_BUNDLE/arch:/output" \archlinux:base-devel@sha256:68bfc3b0d277b08a99101dc9b94aaa03e5ae70cf1b4fb965c03b2b87b915760d \bash -c 'useradd --uid "$CAP_PACKAGE_UID" --create-home cap-package && runuser -u cap-package -- bash /source/scripts/build-linux-arch-package.sh "$1" /output' \- bash "/source/$BUNDLE/deb/Cap_${{ inputs.version }}_amd64.deb"- PACKAGES=("$BUNDLE/arch/"*.pkg.tar.zst)+ bash "/source/$CAP_BUNDLE/deb/Cap_${{ inputs.version }}_amd64.deb"+ PACKAGES=("$CAP_BUNDLE/arch/"*.pkg.tar.zst)test "${#PACKAGES[@]}" -eq 1test -s "${PACKAGES[0]}"test "$(bsdtar -xOf "${PACKAGES[0]}" usr/lib/cap/package-format)" = arch- echo "package=../../${PACKAGES[0]}" >> "$GITHUB_OUTPUT"- name: Verify Windows installer contentsif: ${{ runner.os == 'Windows' }}shell: pwshrun: |- $installers = Get-ChildItem -Path "target/${{ matrix.settings.target }}/release/bundle/nsis" -Filter *.exe- if (-not $installers) {- throw "No Windows NSIS installer was produced."- }$sevenZip = Get-Command 7z -ErrorAction Stop- $requiredFiles = @(- "Cap.exe", "cap-muxer.exe", "cap-exporter.exe", "cap-cli.exe", "cap-gpui.exe",+ $libraries = @("avcodec-61.dll", "avdevice-61.dll", "avfilter-10.dll", "avformat-61.dll","avutil-59.dll", "postproc-58.dll", "swresample-5.dll", "swscale-8.dll","dxcompiler.dll", "dxil.dll", "onnxruntime.dll", "onnxruntime_providers_shared.dll")- foreach ($installer in $installers) {- $contents = & $sevenZip.Source l -slt $installer.FullName- if ($LASTEXITCODE -ne 0) {- throw "Could not inspect Windows installer '$($installer.Name)'."+ $apps = @(+ [pscustomobject]@{+ Bundle = "$env:CAP_BUNDLE/nsis"+ Required = @("Cap.exe", "cap-muxer.exe", "cap-cli.exe") + $libraries+ Forbidden = @("cap-gpui.exe", "cap-exporter.exe", "Cap Classic.exe")+ },+ [pscustomobject]@{+ Bundle = "$env:CLASSIC_BUNDLE/nsis"+ Required = @("Cap Classic.exe", "cap-muxer.exe", "cap-exporter.exe", "cap-cli.exe") + $libraries+ Forbidden = @("cap-gpui.exe", "Cap.exe")+ }+ )+ foreach ($app in $apps) {+ $installers = @(Get-ChildItem -Path $app.Bundle -Filter *.exe)+ if ($installers.Count -ne 1) {+ throw "Expected one Windows NSIS installer in '$($app.Bundle)', found $($installers.Count)."}- foreach ($file in $requiredFiles) {- if ($contents -notcontains "Path = $file") {- throw "Windows installer '$($installer.Name)' is missing bundled '$file'."+ foreach ($installer in $installers) {+ $contents = & $sevenZip.Source l -slt $installer.FullName+ if ($LASTEXITCODE -ne 0) {+ throw "Could not inspect Windows installer '$($installer.Name)'."+ }+ foreach ($file in $app.Required) {+ if ($contents -notcontains "Path = $file") {+ throw "Windows installer '$($installer.Name)' is missing bundled '$file'."+ }+ }+ foreach ($file in $app.Forbidden) {+ if ($contents -contains "Path = $file") {+ throw "Windows installer '$($installer.Name)' unexpectedly bundles '$file'."+ }}}}- - name: Upload unsigned Windows installer+ - name: Stage Windows installers for Authenticode signing+ if: ${{ runner.os == 'Windows' }}+ shell: pwsh+ run: |+ ./scripts/windows-release-signing.ps1 -Operation StageInstallers -Target "${{ matrix.settings.target }}" -WorkspaceRoot "$env:GITHUB_WORKSPACE"++ - name: Upload unsigned Windows installersif: ${{ runner.os == 'Windows' }}id: upload_unsigned_windows_installeruses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2with:name: unsigned-windows-installer- path: target/${{ matrix.settings.target }}/release/bundle/nsis/*.exe+ path: target/${{ matrix.settings.target }}/release/windows-signing/installers/*.exeif-no-files-found: error- name: Submit SignPath signing request@@ -748,63 +881,34 @@ jobs:service-unavailable-timeout-in-seconds: 5400output-artifact-directory: signed-windows-installer- - name: Restore signed Windows installer+ - name: Restore and verify signed Windows installersif: ${{ runner.os == 'Windows' }}shell: pwshrun: |- $signedDir = "signed-windows-installer"- $bundleDir = "target/${{ matrix.settings.target }}/release/bundle/nsis"-- if (-not (Test-Path $signedDir)) {- throw "Signed artifact directory '$signedDir' not found."- }-- $executables = Get-ChildItem -Path $signedDir -Filter *.exe -Recurse- if (-not $executables) {- throw "No signed executables found in '$signedDir'."- }-- Write-Host "Copying signed executables to: $bundleDir"- Copy-Item -Path (Join-Path $signedDir '*.exe') -Destination $bundleDir -Force-- Write-Host "Files in bundle directory after signing:"- Get-ChildItem -Path $bundleDir -Filter *.exe | ForEach-Object { Write-Host " - $($_.Name)" }-- - name: Verify Windows installer Authenticode signature- if: ${{ runner.os == 'Windows' }}- shell: pwsh- run: |- $installers = Get-ChildItem -Path "target/${{ matrix.settings.target }}/release/bundle/nsis" -Filter *.exe- if (-not $installers) {- throw "No Windows installer exists after SignPath signing."- }- foreach ($installer in $installers) {- $signature = Get-AuthenticodeSignature -FilePath $installer.FullName- if ($signature.Status -ne "Valid") {- throw "Windows installer '$($installer.Name)' has invalid Authenticode status: $($signature.Status)."- }- }+ ./scripts/windows-release-signing.ps1 -Operation RestoreInstallers -Target "${{ matrix.settings.target }}" -WorkspaceRoot "$env:GITHUB_WORKSPACE"- name: Verify extracted Windows payload signatures and hashesif: ${{ runner.os == 'Windows' }}shell: pwshrun: |- $installers = Get-ChildItem -Path "target/${{ matrix.settings.target }}/release/bundle/nsis" -Filter *.exe- if (-not $installers) {- throw "No Windows installer exists for extracted payload verification."- }- foreach ($installer in $installers) {- ./scripts/windows-release-signing.ps1 -Operation VerifyInstaller -Target "${{ matrix.settings.target }}" -WorkspaceRoot "$env:GITHUB_WORKSPACE" -InstallerPath $installer.FullName+ foreach ($app in @(+ [pscustomobject]@{ Name = "cap"; Bundle = "$env:CAP_BUNDLE/nsis" },+ [pscustomobject]@{ Name = "classic"; Bundle = "$env:CLASSIC_BUNDLE/nsis" }+ )) {+ $installers = @(Get-ChildItem -Path $app.Bundle -Filter *.exe)+ if ($installers.Count -ne 1) {+ throw "Expected one signed installer in '$($app.Bundle)', found $($installers.Count)."+ }+ ./scripts/windows-release-signing.ps1 -Operation VerifyInstaller -App $app.Name -Target "${{ matrix.settings.target }}" -WorkspaceRoot "$env:GITHUB_WORKSPACE" -InstallerPath $installers[0].FullName}- - name: Re-sign Windows installer for Tauri updater+ - name: Re-sign Windows installers for the updaterif: ${{ runner.os == 'Windows' }}shell: bashworking-directory: apps/desktoprun: |- BUNDLE_DIR="../../target/${{ matrix.settings.target }}/release/bundle/nsis"- for exe in "$BUNDLE_DIR"/*.exe; do- echo "Re-signing $(basename "$exe") for Tauri updater..."+ for exe in "../../$CAP_BUNDLE"/nsis/*.exe "../../$CLASSIC_BUNDLE"/nsis/*.exe; do+ echo "Re-signing $(basename "$exe") for the updater..."rm -f "${exe}.sig"bun run tauri signer sign -k "$TAURI_SIGNING_PRIVATE_KEY" -p "$TAURI_SIGNING_PRIVATE_KEY_PASSWORD" "$exe"if [[ ! -s "${exe}.sig" ]]; then@@ -812,8 +916,7 @@ jobs:exit 1fidone- echo "Signature files after re-signing:"- ls -la "$BUNDLE_DIR"/*.sig+ ls -la "../../$CAP_BUNDLE"/nsis/*.sig "../../$CLASSIC_BUNDLE"/nsis/*.sigenv:TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}@@ -823,58 +926,141 @@ jobs:with:name: desktop-release-${{ matrix.settings.target }}-${{ inputs.sha }}path: |- target/${{ matrix.settings.target }}/release/bundle/dmg/*.dmg- target/${{ matrix.settings.target }}/release/bundle/nsis/*.exe- target/${{ matrix.settings.target }}/release/bundle/nsis/*.sig+ ${{ env.CAP_BUNDLE }}/dmg/*.dmg+ ${{ env.CAP_BUNDLE }}/macos/*.tar.gz+ ${{ env.CAP_BUNDLE }}/macos/*.sig+ ${{ env.CAP_BUNDLE }}/nsis/*.exe+ ${{ env.CAP_BUNDLE }}/nsis/*.sig+ ${{ env.CAP_BUNDLE }}/deb/*.deb+ ${{ env.CAP_BUNDLE }}/deb/*.sig+ ${{ env.CAP_BUNDLE }}/appimage/*.AppImage+ ${{ env.CAP_BUNDLE }}/appimage/*.sig+ ${{ env.CLASSIC_BUNDLE }}/dmg/*.dmg+ ${{ env.CLASSIC_BUNDLE }}/macos/*.tar.gz+ ${{ env.CLASSIC_BUNDLE }}/macos/*.sig+ ${{ env.CLASSIC_BUNDLE }}/nsis/*.exe+ ${{ env.CLASSIC_BUNDLE }}/nsis/*.sig+ ${{ env.CLASSIC_BUNDLE }}/appimage/*.AppImage+ ${{ env.CLASSIC_BUNDLE }}/appimage/*.sigtarget/${{ matrix.settings.target }}/release/windows-signing/payload-manifest.json- target/${{ matrix.settings.target }}/release/bundle/deb/*.deb- target/${{ matrix.settings.target }}/release/bundle/deb/*.sig- target/${{ matrix.settings.target }}/release/bundle/appimage/*.AppImage- target/${{ matrix.settings.target }}/release/bundle/appimage/*.sigif-no-files-found: errorretention-days: 3compression-level: 0- - name: Upload assets- if: ${{ runner.os != 'Linux' }}+ - name: Locate release assets+ id: assets+ shell: bash+ run: |+ set -euo pipefail+ shopt -s nullglob+ one() {+ if [[ $# -ne 1 || ! -s "$1" ]]; then+ echo "::error::Expected exactly one non-empty release asset, found $# ($*)." >&2+ exit 1+ fi+ printf '%s' "$1"+ }+ {+ case "$RUNNER_OS" in+ macOS)+ echo "cap_dmg=$(one "$CAP_BUNDLE"/dmg/*.dmg)"+ echo "cap_update=$(one "$CAP_BUNDLE"/macos/*.app.tar.gz)"+ echo "classic_dmg=$(one "$CLASSIC_BUNDLE"/dmg/*.dmg)"+ echo "classic_update=$(one "$CLASSIC_BUNDLE"/macos/*.app.tar.gz)"+ ;;+ Windows)+ echo "cap_installer=$(one "$CAP_BUNDLE"/nsis/*.exe)"+ echo "classic_installer=$(one "$CLASSIC_BUNDLE"/nsis/*.exe)"+ ;;+ Linux)+ echo "cap_deb=$(one "$CAP_BUNDLE"/deb/*.deb)"+ echo "cap_appimage=$(one "$CAP_BUNDLE"/appimage/*.AppImage)"+ echo "cap_arch=$(one "$CAP_BUNDLE"/arch/*.pkg.tar.zst)"+ echo "classic_appimage=$(one "$CLASSIC_BUNDLE"/appimage/*.AppImage)"+ if [[ "$VERSION" != *-* ]]; then+ echo "cap_rpm=$(one "$CAP_BUNDLE"/rpm/*.rpm)"+ fi+ ;;+ esac+ } >> "$GITHUB_OUTPUT"+ env:+ VERSION: ${{ inputs.version }}++ - name: Upload Cap macOS disk image+ if: ${{ runner.os == 'macOS' }}uses: crabnebula-dev/cloud-release@v0with:- working-directory: apps/desktop- command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --framework tauri ${{ env.CN_CHANNEL_FLAG }}+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.cap_dmg }}" --public-platform dmg-${{ matrix.settings.arch }} ${{ env.CN_CHANNEL_FLAG }}+ api-key: ${{ secrets.CN_API_KEY }}++ - name: Upload Cap macOS update+ if: ${{ runner.os == 'macOS' }}+ uses: crabnebula-dev/cloud-release@v0+ with:+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.cap_update }}" --signature "${{ steps.assets.outputs.cap_update }}.sig" --update-platform darwin-${{ matrix.settings.arch }} ${{ env.CN_CHANNEL_FLAG }}+ api-key: ${{ secrets.CN_API_KEY }}++ - name: Upload Cap Classic macOS disk image+ if: ${{ runner.os == 'macOS' }}+ uses: crabnebula-dev/cloud-release@v0+ with:+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.classic_dmg }}" --public-platform dmg-${{ matrix.settings.arch }}-classic ${{ env.CN_CHANNEL_FLAG }}+ api-key: ${{ secrets.CN_API_KEY }}++ - name: Upload Cap Classic macOS update+ if: ${{ runner.os == 'macOS' }}+ uses: crabnebula-dev/cloud-release@v0+ with:+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.classic_update }}" --signature "${{ steps.assets.outputs.classic_update }}.sig" --update-platform darwin-${{ matrix.settings.arch }}-classic ${{ env.CN_CHANNEL_FLAG }}+ api-key: ${{ secrets.CN_API_KEY }}++ - name: Upload Cap Windows installer+ if: ${{ runner.os == 'Windows' }}+ uses: crabnebula-dev/cloud-release@v0+ with:+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.cap_installer }}" --signature "${{ steps.assets.outputs.cap_installer }}.sig" --public-platform nsis-${{ matrix.settings.arch }} --update-platform windows-${{ matrix.settings.arch }} ${{ env.CN_CHANNEL_FLAG }}+ api-key: ${{ secrets.CN_API_KEY }}++ - name: Upload Cap Classic Windows installer+ if: ${{ runner.os == 'Windows' }}+ uses: crabnebula-dev/cloud-release@v0+ with:+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.classic_installer }}" --signature "${{ steps.assets.outputs.classic_installer }}.sig" --public-platform nsis-${{ matrix.settings.arch }}-classic --update-platform windows-${{ matrix.settings.arch }}-classic ${{ env.CN_CHANNEL_FLAG }}api-key: ${{ secrets.CN_API_KEY }}- env:- TAURI_BUNDLE_PATH: ../..- - name: Upload Linux deb asset+ - name: Upload Cap Linux debif: ${{ runner.os == 'Linux' }}uses: crabnebula-dev/cloud-release@v0with:- working-directory: apps/desktop- command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "../../target/${{ matrix.settings.target }}/release/bundle/deb/Cap_${{ inputs.version }}_amd64.deb" --signature "../../target/${{ matrix.settings.target }}/release/bundle/deb/Cap_${{ inputs.version }}_amd64.deb.sig" --public-platform deb-x86_64 --update-platform linux-x86_64-deb ${{ env.CN_CHANNEL_FLAG }}+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.cap_deb }}" --signature "${{ steps.assets.outputs.cap_deb }}.sig" --public-platform deb-x86_64 --update-platform linux-x86_64-deb ${{ env.CN_CHANNEL_FLAG }}api-key: ${{ secrets.CN_API_KEY }}- - name: Upload Linux AppImage asset+ - name: Upload Cap Linux AppImageif: ${{ runner.os == 'Linux' }}uses: crabnebula-dev/cloud-release@v0with:- working-directory: apps/desktop- command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "../../target/${{ matrix.settings.target }}/release/bundle/appimage/Cap_${{ inputs.version }}_amd64.AppImage" --signature "../../target/${{ matrix.settings.target }}/release/bundle/appimage/Cap_${{ inputs.version }}_amd64.AppImage.sig" --public-platform appimage-x86_64 --update-platform linux-x86_64-appimage ${{ env.CN_CHANNEL_FLAG }}+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.cap_appimage }}" --signature "${{ steps.assets.outputs.cap_appimage }}.sig" --public-platform appimage-x86_64 --update-platform linux-x86_64-appimage ${{ env.CN_CHANNEL_FLAG }}api-key: ${{ secrets.CN_API_KEY }}- - name: Upload Linux RPM asset+ - name: Upload Cap Linux RPMif: ${{ runner.os == 'Linux' && !contains(inputs.version, '-') }}uses: crabnebula-dev/cloud-release@v0with:- working-directory: apps/desktop- command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "../../target/${{ matrix.settings.target }}/release/bundle/rpm/Cap-${{ inputs.version }}-1.x86_64.rpm" --public-platform rpm-x86_64 ${{ env.CN_CHANNEL_FLAG }}+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.cap_rpm }}" --public-platform rpm-x86_64 ${{ env.CN_CHANNEL_FLAG }}+ api-key: ${{ secrets.CN_API_KEY }}++ - name: Upload Cap Arch Linux package+ if: ${{ runner.os == 'Linux' }}+ uses: crabnebula-dev/cloud-release@v0+ with:+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.cap_arch }}" --public-platform pacman-x86_64 ${{ env.CN_CHANNEL_FLAG }}api-key: ${{ secrets.CN_API_KEY }}- - name: Upload Arch Linux asset+ - name: Upload Cap Classic Linux AppImageif: ${{ runner.os == 'Linux' }}uses: crabnebula-dev/cloud-release@v0with:- working-directory: apps/desktop- command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.build_arch.outputs.package }}" --public-platform pacman-x86_64 ${{ env.CN_CHANNEL_FLAG }}+ command: release upload ${{ env.CN_APPLICATION }} "${{ inputs.version }}" --file "${{ steps.assets.outputs.classic_appimage }}" --signature "${{ steps.assets.outputs.classic_appimage }}.sig" --public-platform appimage-x86_64-classic --update-platform linux-x86_64-appimage-classic ${{ env.CN_CHANNEL_FLAG }}api-key: ${{ secrets.CN_API_KEY }}- uses: matbour/setup-sentry-cli@8ef22a4ff03bcd1ebbcaa3a36a81482ca8e3872e@@ -885,7 +1071,7 @@ jobs:env:SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}run: |- sentry-cli debug-files upload -o ${{ env.SENTRY_ORG }} -p ${{ env.SENTRY_PROJECT }} target/Cap.dSYM+ sentry-cli debug-files upload -o ${{ env.SENTRY_ORG }} -p ${{ env.SENTRY_PROJECT }} "target/Cap Classic.dSYM"- name: Upload debug symbols to Sentryif: ${{ runner.os == 'Windows' }}diff --git a/AGENTS.md b/AGENTS.mdindex de4484400..18a3723b2 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -50,7 +50,7 @@ Additionally, `unused_must_use = "deny"` applies to all Rust code: every `Result## Project Structure & Modules- Turborepo monorepo:- - `apps/desktop` (Tauri v2 + SolidStart), `apps/web` (Next.js), `apps/cli` (Rust CLI).+ - `apps/desktop-gpui` (GPUI, ships as Cap), `apps/desktop` (Tauri v2 + SolidStart, ships separately as Cap Classic), `apps/web` (Next.js), `apps/cli` (Rust CLI).- `packages/*` shared libs (e.g., `database`, `ui`, `ui-solid`, `utils`, `web-*`).- `crates/*` Rust media/recording/rendering/camera crates.- `scripts/*`, `infra/`, and `packages/local-docker/` for tooling and local services.@@ -59,7 +59,7 @@ Additionally, `unused_must_use = "deny"` applies to all Rust code: every `Result## Build, Test, Develop- Install: `bun install`; setup: `bun run env-setup` then `bun run cap-setup`.- Dev: `bun run dev` (web+desktop). Desktop only: `bun run dev:desktop`. Web only: `bun run dev:web` or `cd apps/web && bun run dev`.-- Build: `bun run build` (Turbo). Desktop release: `bun run tauri:build`.+- Build: `bun run build` (Turbo). Desktop release: `bun run gpui:build <target>` for Cap (GPUI) and `bun run tauri:build` for Cap Classic (Tauri).- DB: `bun run db:generate` → `bun run db:push` → `bun run db:studio`.- Docker: `bun run docker:up | docker:stop | docker:clean`.- Quality: `bun run lint`, `bun run format`, `bun run typecheck`. Rust: `cargo build -p <crate>`, `cargo test -p <crate>`.diff --git a/package.json b/package.jsonindex bb12861f1..bc7c64c9a 100644--- a/package.json+++ b/package.json@@ -28,6 +28,7 @@"docker:up": "turbo run docker:up","format": "bun run biome check --write","lint": "bun run biome lint",+ "gpui:build": "dotenv -e .env -- node scripts/bundle-gpui.mjs","tauri:build": "dotenv -e .env -- bun run --cwd apps/desktop build:tauri --config src-tauri/tauri.prod.conf.json --verbose","typecheck": "bun run --cwd apps/web next typegen && bun run tsc -b","test": "turbo run test",diff --git a/scripts/build-gpui-binary.sh b/scripts/build-gpui-binary.shindex 8c696a764..e185a01e1 100755--- a/scripts/build-gpui-binary.sh+++ b/scripts/build-gpui-binary.sh@@ -6,7 +6,6 @@ requested_target="${2:-${RUST_TARGET_TRIPLE:-}}"toolchain="${CAP_GPUI_RUST_TOOLCHAIN:-1.95.0}"repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"gpui_dir="$repo_root/apps/desktop-gpui"-binaries_dir="$repo_root/apps/desktop/src-tauri/binaries"case "$profile" indebug)@@ -61,7 +60,6 @@ node "$repo_root/scripts/sync-desktop-versions.mjs")source_binary="$artifact_dir/cap-gpui$extension"-staged_binary="$binaries_dir/cap-gpui-$target$extension"if [[ ! -f "$source_binary" ]]; thenecho "error: built GPUI binary not found at $source_binary" >&2exit 1@@ -75,9 +73,4 @@ if [[ "$target" == *linux* ]]; thenpatchelf --set-rpath '$ORIGIN:$ORIGIN/../lib/cap' "$source_binary"fi-mkdir -p "$binaries_dir"-cp "$source_binary" "$staged_binary"-if [[ "$extension" != ".exe" ]]; then- chmod +x "$staged_binary"-fi-echo "Staged $source_binary -> $staged_binary"+echo "Built $source_binary"diff --git a/scripts/build-linux-arch-package.sh b/scripts/build-linux-arch-package.shindex 806c0df16..ce972e328 100644--- a/scripts/build-linux-arch-package.sh+++ b/scripts/build-linux-arch-package.sh@@ -49,7 +49,7 @@ pkgdesc="Screen recording with Studio, Instant, and screenshot modes"arch=("$architecture")url="https://cap.so"license=("AGPL-3.0-only")-depends=("webkit2gtk-4.1" "gtk3" "libappindicator-gtk3" "libva" "libpulse" "libpipewire" "alsa-lib" "alsa-plugins" "libxkbcommon" "libxkbcommon-x11" "openssl" "vulkan-icd-loader" "xdg-desktop-portal" "xdg-utils" "gst-plugins-good" "gst-libav")+depends=("libva" "libpulse" "libpipewire" "alsa-lib" "alsa-plugins" "libxkbcommon" "libxkbcommon-x11" "libx11" "openssl" "wayland" "libglvnd" "vulkan-icd-loader" "xdg-desktop-portal" "xdg-utils")optdepends=("xdg-desktop-portal-hyprland: screen capture on Hyprland and Omarchy" "vulkan-driver: hardware accelerated recording and editing")provides=("cap=\$pkgver")conflicts=("cap")@@ -60,7 +60,7 @@ sha256sums=("$checksum")package() {bsdtar -xOf "\$srcdir/Cap.deb" "$data_member" | bsdtar -xf - -C "\$pkgdir"- for binary in Cap cap-gpui cap-cli cap-exporter cap-muxer; do+ for binary in Cap cap-cli cap-muxer; dotest -x "\$pkgdir/usr/bin/\$binary"doneprintf 'arch\n' > "\$pkgdir/usr/lib/cap/package-format"diff --git a/scripts/build-linux-packages.mjs b/scripts/build-linux-packages.mjsindex 4232af135..812600f6c 100644--- a/scripts/build-linux-packages.mjs+++ b/scripts/build-linux-packages.mjs@@ -1,20 +1,32 @@import { readdir } from "node:fs/promises";import path from "node:path";import { fileURLToPath } from "node:url";+import { gpuiDirectory } from "./bundle-gpui.mjs";import {finalizeLinuxAppImage,runCommand,} from "./finalize-linux-appimage.mjs";-import { supportedLinuxBundles } from "./linux-bundle-config.mjs";+import {+ finalizeGpuiDeb,+ finalizeGpuiRpm,+} from "./finalize-linux-gpui-packages.mjs";+import {+ supportedLinuxBundles,+ supportedLinuxClassicBundles,+} from "./linux-bundle-config.mjs";-const [target, ...args] = process.argv.slice(2);+const repoRoot = fileURLToPath(new URL("..", import.meta.url));+const desktopDirectory = path.join(repoRoot, "apps", "desktop");++const [target, app, ...args] = process.argv.slice(2);if (process.platform !== "linux" ||!/^\w+-unknown-linux-gnu$/.test(target ?? "") ||+ (app !== "cap" && app !== "classic") ||args.some((arg) => /^--(?:target|bundles|debug|profile)(?:=|$)/.test(arg))) {throw new Error(- "Run on Linux: node scripts/build-linux-packages.mjs <target> [tauri build options]",+ "Run on Linux: node scripts/build-linux-packages.mjs <target> <cap|classic> [tauri options]",);}if (!process.env.TAURI_SIGNING_PRIVATE_KEY) {@@ -23,46 +35,78 @@ if (!process.env.TAURI_SIGNING_PRIVATE_KEY) {);}-const desktopDirectory = fileURLToPath(- new URL("../apps/desktop/", import.meta.url),-);-const metadata = runCommand(- "cargo",- ["metadata", "--no-deps", "--format-version", "1"],- {- cwd: path.join(desktopDirectory, "src-tauri"),- encoding: "utf8",- stdio: ["ignore", "pipe", "inherit"],- },-);-const workspace = JSON.parse(metadata.stdout);-const targetDirectory = workspace.target_directory;-const version = workspace.packages.find(+function cargoMetadata(cwd) {+ return JSON.parse(+ runCommand("cargo", ["metadata", "--no-deps", "--format-version", "1"], {+ cwd,+ encoding: "utf8",+ stdio: ["ignore", "pipe", "inherit"],+ }).stdout,+ );+}++const classic = cargoMetadata(path.join(desktopDirectory, "src-tauri"));+const version = classic.packages.find((pkg) => pkg.name === "cap-desktop",)?.version;if (!version) throw new Error("Desktop version is missing from Cargo metadata");-const bundles = supportedLinuxBundles(version).join(",");-runCommand(- "bun",- ["run", "build:tauri", "--target", target, "--bundles", bundles, ...args],- {- cwd: desktopDirectory,- env: { ...process.env, RUST_TARGET_TRIPLE: target },- },-);+let targetDirectory;+if (app === "classic") {+ targetDirectory = classic.target_directory;+ runCommand(+ "bun",+ [+ "run",+ "build:tauri",+ "--target",+ target,+ "--bundles",+ supportedLinuxClassicBundles().join(","),+ ...args,+ ],+ {+ cwd: desktopDirectory,+ env: { ...process.env, RUST_TARGET_TRIPLE: target },+ },+ );+} else {+ targetDirectory = path.join(gpuiDirectory, "target");+ runCommand(+ "node",+ [+ path.join(repoRoot, "scripts", "bundle-gpui.mjs"),+ target,+ "--bundles",+ supportedLinuxBundles(version).join(","),+ ...args,+ ],+ { env: { ...process.env, RUST_TARGET_TRIPLE: target } },+ );+}++const bundleRoot = path.join(targetDirectory, target, "release/bundle");-const bundleDirectory = path.join(- targetDirectory,- target,- "release/bundle/appimage",-);-const images = (await readdir(bundleDirectory)).filter((file) =>- file.endsWith(".AppImage"),-);+async function bundledArtifacts(format, extension) {+ const directory = path.join(bundleRoot, format);+ const files = (await readdir(directory).catch(() => [])).filter((file) =>+ file.endsWith(extension),+ );+ return files.map((file) => path.join(directory, file));+}++const images = await bundledArtifacts("appimage", ".AppImage");if (images.length !== 1) {throw new Error(- `Expected one AppImage in ${bundleDirectory}, found ${images.length}`,+ `Expected one AppImage in ${bundleRoot}/appimage, found ${images.length}`,);}-await finalizeLinuxAppImage(path.join(bundleDirectory, images[0]));+if (app === "cap") {+ for (const deb of await bundledArtifacts("deb", ".deb")) {+ await finalizeGpuiDeb(deb);+ }+ for (const rpm of await bundledArtifacts("rpm", ".rpm")) {+ await finalizeGpuiRpm(rpm);+ }+}+await finalizeLinuxAppImage(images[0], { webview: app === "classic" });diff --git a/scripts/build-macos-packages.mjs b/scripts/build-macos-packages.mjsindex ee549c2f8..27d6e5026 100644--- a/scripts/build-macos-packages.mjs+++ b/scripts/build-macos-packages.mjs@@ -69,12 +69,17 @@ function validateArguments(target, args, platform) {/^(?:aarch64|x86_64)-apple-darwin$/.test(target ?? "");for (let index = 0; index < args.length && valid; index++) {const argument = args[index];- if (argument === "--config" || argument === "-c") {+ if (+ argument === "--config" ||+ argument === "-c" ||+ argument === "--bundles" ||+ argument === "-b"+ ) {const value = args[++index];valid = Boolean(value) && !value.startsWith("-");} else {valid =- /^--config=.+/.test(argument) ||+ /^--(?:config|bundles)=.+/.test(argument) ||argument === "--verbose" ||/^-v{1,2}$/.test(argument);}@@ -147,6 +152,7 @@ export async function buildMacosPackages(target,args = [],{+ app = "classic",platform = process.platform,env = process.env,signal,@@ -157,6 +163,9 @@ export async function buildMacosPackages(} = {},) {validateArguments(target, args, platform);+ if (app !== "classic" && app !== "cap") {+ throw new Error(`Unknown macOS app to package: ${app}`);+ }const commandArguments = ["--target", target, ...args];const environment = {...env,@@ -179,7 +188,7 @@ export async function buildMacosPackages(signal?.throwIfAborted();let outputTail = "";const command =- attempt === 0+ attempt === 0 && app === "classic"? ["build:tauri", ...commandArguments]: ["dotenv",diff --git a/scripts/build-macos-packages.test.mjs b/scripts/build-macos-packages.test.mjsindex 84418688d..6c9190617 100644--- a/scripts/build-macos-packages.test.mjs+++ b/scripts/build-macos-packages.test.mjs@@ -64,23 +64,57 @@ test("macOS packaging uses the ScreenCaptureKit minimum across both app manifestconst minimum = resolveMacosDeploymentTarget();assert.equal(minimum, "12.3");assert.equal(resolveMacosDeploymentTarget(""), minimum);- const cargo = readFileSync(- new URL("../apps/desktop-gpui/Cargo.toml", import.meta.url),- "utf8",+ const gpui = JSON.parse(+ readFileSync(+ new URL("../apps/desktop-gpui/tauri.conf.json", import.meta.url),+ "utf8",+ ),);- const plist = readFileSync(- new URL("../apps/desktop-gpui/resources/Info.plist", import.meta.url),- "utf8",+ assert.equal(gpui.bundle.macOS.minimumSystemVersion, minimum);+});++test("the GPUI app is packaged by rebundling its prebuilt binary on every attempt", async () => {+ const fixture = harness([+ { code: 1, output: armTimestampFailure },+ { code: 0 },+ ]);+ fixture.options.env.TAURI_APP_PATH = "/repo/apps/desktop-gpui";+ const result = await buildMacosPackages(+ target,+ ["--bundles", "app,dmg", "--verbose"],+ {+ ...fixture.options,+ app: "cap",+ },);- assert.equal(- cargo.match(/osx_minimum_system_version\s*=\s*"([^"]+)"/)?.[1],- minimum,+ assert.equal(result.code, 0);+ const bundle = [+ "dotenv",+ "-e",+ "../../.env",+ "--",+ "bun",+ "run",+ "tauri",+ "bundle",+ "--target",+ target,+ "--bundles",+ "app,dmg",+ "--verbose",+ "--config",+ JSON.stringify({ bundle: { macOS: { minimumSystemVersion: "12.3" } } }),+ ];+ assert.deepEqual(+ fixture.calls.map((call) => call.args),+ [bundle, bundle],);- assert.equal(- plist.match(- /<key>LSMinimumSystemVersion<\/key>\s*<string>([^<]+)<\/string>/,- )?.[1],- minimum,+ for (const call of fixture.calls) {+ assert.equal(call.env.TAURI_APP_PATH, "/repo/apps/desktop-gpui");+ }+ await assert.rejects(+ buildMacosPackages(target, [], { ...fixture.options, app: "other" }),+ /Unknown macOS app/,);});@@ -477,6 +511,8 @@ test("unsupported platforms and arguments fail before executing bun", async () =["darwin", target, ["--target", "aarch64-apple-darwin"]],["darwin", target, ["--skip-stapling"]],["darwin", target, ["--no-bundle"]],+ ["darwin", target, ["--bundles"]],+ ["darwin", target, ["--bundles", "--verbose"]],]) {const fixture = harness([]);await assert.rejects(diff --git a/scripts/bundle-gpui-mac b/scripts/bundle-gpui-macdeleted file mode 100755index 449f6f00b..000000000--- a/scripts/bundle-gpui-mac+++ /dev/null@@ -1,104 +0,0 @@-#!/usr/bin/env bash-set -euo pipefail--repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"-gpui_dir="$repo_root/apps/desktop-gpui"-target_dir="${CARGO_TARGET_DIR:-$gpui_dir/target}"-framework="$repo_root/target/native-deps/Spacedrive.framework"-backgrounds="$repo_root/apps/desktop/src-tauri/assets/backgrounds"-onnxruntime="$repo_root/target/native-deps/onnxruntime"-icon="$repo_root/apps/desktop/src-tauri/icons/macos/icon.icns"-info_plist="$gpui_dir/resources/Info.plist"-entitlements="$repo_root/apps/desktop/src-tauri/Entitlements.plist"-target_triple="$(rustc -vV | awk '/^host:/ { host = $2 } END { print host }')"-sidecars="$repo_root/apps/desktop/src-tauri/binaries"-MACOSX_DEPLOYMENT_TARGET="$(node "$repo_root/scripts/build-macos-packages.mjs" --deployment-target)"-export MACOSX_DEPLOYMENT_TARGET--if [[ "$target_dir" != /* ]]; then- target_dir="$gpui_dir/$target_dir"-fi--if [[ ! -d "$framework" ]]; then- echo "Missing $framework" >&2- exit 1-fi--if [[ ! -d "$backgrounds" ]]; then- echo "Missing $backgrounds" >&2- exit 1-fi--for file in "$icon" "$info_plist" "$entitlements"; do- if [[ ! -f "$file" ]]; then- echo "Missing $file" >&2- exit 1- fi-done--for binary in cap-cli cap-exporter cap-muxer; do- if [[ ! -x "$sidecars/$binary-$target_triple" ]]; then- echo "Missing $sidecars/$binary-$target_triple" >&2- exit 1- fi-done--if [[ "${CAP_GPUI_BUNDLE_SKIP_BUILD:-0}" != "1" ]]; then- pushd "$gpui_dir" >/dev/null- cargo build --release- popd >/dev/null-fi--binary_path="$target_dir/release/cap-gpui"-if [[ ! -x "$binary_path" ]]; then- echo "Missing $binary_path" >&2- exit 1-fi--app_version="$(cd "$gpui_dir" && cargo metadata --locked --offline --no-deps --format-version 1 | node -e '-let input = "";-process.stdin.setEncoding("utf8");-process.stdin.on("data", chunk => input += chunk);-process.stdin.on("end", () => {- const pkg = JSON.parse(input).packages.find(pkg => pkg.name === "cap-desktop-gpui");- const version = pkg?.version.match(/^(\d+\.\d+\.\d+)(?:[-+].*)?$/)?.[1];- if (!version) throw new Error("Missing or invalid GPUI package version");- console.log(version);-});-')"--app_path="$target_dir/release/bundle/osx/Cap GPUI.app"-contents="$app_path/Contents"--rm -rf "$app_path"-mkdir -p "$contents/MacOS" "$contents/Frameworks" "$contents/Resources/assets"-/usr/bin/ditto "$binary_path" "$contents/MacOS/cap-gpui"-/usr/bin/ditto "$info_plist" "$contents/Info.plist"-/usr/libexec/PlistBuddy -c "Set :LSMinimumSystemVersion $MACOSX_DEPLOYMENT_TARGET" "$contents/Info.plist"-/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $app_version" "$contents/Info.plist"-/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $app_version" "$contents/Info.plist"-/usr/bin/ditto "$icon" "$contents/Resources/icon.icns"-rm -rf "$contents/Frameworks/Spacedrive.framework"-/usr/bin/ditto "$framework" "$contents/Frameworks/Spacedrive.framework"-rm -rf "$contents/Resources/assets/backgrounds"-/usr/bin/ditto "$backgrounds" "$contents/Resources/assets/backgrounds"--if [[ -d "$onnxruntime" ]]; then- rm -rf "$contents/Resources/onnxruntime"- /usr/bin/ditto "$onnxruntime" "$contents/Resources/onnxruntime"-fi--rm -f "$contents/MacOS/cap-cli" "$contents/MacOS/cap-exporter" "$contents/MacOS/cap-muxer"-/usr/bin/ditto "$sidecars/cap-cli-$target_triple" "$contents/MacOS/cap-cli"-/usr/bin/ditto "$sidecars/cap-muxer-$target_triple" "$contents/MacOS/cap-muxer"-if cmp -s "$sidecars/cap-cli-$target_triple" "$sidecars/cap-exporter-$target_triple"; then- ln -s "cap-cli" "$contents/MacOS/cap-exporter"-else- /usr/bin/ditto "$sidecars/cap-exporter-$target_triple" "$contents/MacOS/cap-exporter"-fi--/usr/bin/plutil -lint "$contents/Info.plist"-/usr/bin/codesign --force --deep --entitlements "$entitlements" --sign - "$app_path"-/usr/bin/codesign --verify --deep --strict "$app_path"--printf '%s\n' "$app_path"diff --git a/scripts/bundle-gpui.mjs b/scripts/bundle-gpui.mjsnew file mode 100644index 000000000..8d2bb50c0--- /dev/null+++ b/scripts/bundle-gpui.mjs@@ -0,0 +1,193 @@+import { spawnSync } from "node:child_process";+import { createHash } from "node:crypto";+import * as fs from "node:fs/promises";+import path from "node:path";+import { fileURLToPath } from "node:url";+import { buildMacosPackages } from "./build-macos-packages.mjs";++const repoRoot = path.resolve(+ path.dirname(fileURLToPath(import.meta.url)),+ "..",+);+export const gpuiDirectory = path.join(repoRoot, "apps", "desktop-gpui");+const desktopDirectory = path.join(repoRoot, "apps", "desktop");+export const gpuiToolchain = process.env.CAP_GPUI_RUST_TOOLCHAIN || "1.95.0";++const platformConfigNames = {+ darwin: "tauri.macos.conf.json",+ win32: "tauri.windows.conf.json",+ linux: "tauri.linux.conf.json",+};++export function targetPlatform(target) {+ if (/-apple-darwin$/.test(target)) return "darwin";+ if (/-pc-windows-msvc$/.test(target)) return "win32";+ if (/-unknown-linux-gnu$/.test(target)) return "linux";+ return null;+}++export function mainBinaryName(target) {+ return targetPlatform(target) === "win32" ? "Cap.exe" : "Cap";+}++export function gpuiBinaryPath(target, profile = "release") {+ const extension = targetPlatform(target) === "win32" ? ".exe" : "";+ return path.join(+ gpuiDirectory,+ "target",+ target,+ profile,+ `cap-gpui${extension}`,+ );+}++export function gpuiPlatformConfig(platform) {+ if (platform === "darwin") {+ return {+ bundle: {+ resources: {+ "../../target/native-deps/onnxruntime/lib/libonnxruntime.dylib":+ "onnxruntime/lib/libonnxruntime.dylib",+ },+ },+ };+ }+ if (platform === "win32") {+ return {+ bundle: {+ resources: {+ "../../target/ffmpeg/bin/*.dll": "./",+ "../../target/native-deps/dxc/*.dll": "./",+ "../../target/native-deps/dxc/LICENSE-*.txt": "licenses/dxc/",+ "../../target/native-deps/onnxruntime/lib/*.dll": "./",+ },+ },+ };+ }+ return null;+}++export function bundleArguments(target, args) {+ return ["tauri", "bundle", "--target", target, ...args];+}++export function bundleEnvironment(env) {+ return {+ ...env,+ TAURI_APP_PATH: gpuiDirectory,+ RUSTUP_TOOLCHAIN: gpuiToolchain,+ };+}++function validate(target, args) {+ const platform = targetPlatform(target ?? "");+ if (!platform || platform !== process.platform) {+ throw new Error(+ "Run on the target platform: node scripts/bundle-gpui.mjs <target-triple> [--skip-build] [--no-bundle] [tauri bundle options]",+ );+ }+ if (args.some((argument) => /^--(?:target|debug)(?:=|$)/.test(argument))) {+ throw new Error("The GPUI bundle is always a release build for <target>");+ }+ return platform;+}++function run(command, args, options = {}) {+ const result = spawnSync(command, args, { stdio: "inherit", ...options });+ if (result.error) throw result.error;+ if (result.status !== 0) {+ throw new Error(+ `${command} ${args.join(" ")} failed with ${result.signal ?? result.status}`,+ );+ }+}++const sha256 = (contents) =>+ createHash("sha256").update(contents).digest("hex");++export async function stageMainBinary(target) {+ const source = gpuiBinaryPath(target);+ const destination = path.join(path.dirname(source), mainBinaryName(target));+ const built = await fs.readFile(source);+ if (built.length === 0) throw new Error(`${source} is empty`);+ await fs.copyFile(source, destination);+ await fs.chmod(destination, (await fs.stat(source)).mode & 0o7777);+ if (sha256(await fs.readFile(destination)) !== sha256(built)) {+ throw new Error(`${destination} does not match ${source}`);+ }+ return destination;+}++export async function writePlatformConfig(platform) {+ const config = gpuiPlatformConfig(platform);+ if (!config) return null;+ const file = path.join(gpuiDirectory, platformConfigNames[platform]);+ const contents = `${JSON.stringify(config, null, "\t")}\n`;+ const current = await fs.readFile(file, "utf8").catch(() => undefined);+ if (current !== contents) await fs.writeFile(file, contents);+ return file;+}++export function parseOptions(args) {+ const flags = new Set(["--skip-build", "--no-bundle"]);+ return {+ skipBuild: args.includes("--skip-build"),+ noBundle: args.includes("--no-bundle"),+ bundleArgs: args.filter((argument) => !flags.has(argument)),+ };+}++export async function bundleGpui(target, args, { env = process.env } = {}) {+ const { skipBuild, noBundle, bundleArgs } = parseOptions(args);+ const platform = validate(target, bundleArgs);++ if (!skipBuild) {+ run("bash", [+ path.join(repoRoot, "scripts", "build-gpui-binary.sh"),+ "release",+ target,+ ]);+ }+ const staged = await stageMainBinary(target);+ console.log(`Staged ${staged}`);+ if (noBundle) return;+ await writePlatformConfig(platform);+ if (platform === "linux") {+ await fs+ .access(path.join(gpuiDirectory, platformConfigNames.linux))+ .catch(() => {+ throw new Error(+ "Missing apps/desktop-gpui/tauri.linux.conf.json; run `RUST_TARGET_TRIPLE=<target> bun run cap-setup` first",+ );+ });+ }++ if (platform === "darwin") {+ const result = await buildMacosPackages(target, bundleArgs, {+ app: "cap",+ env: bundleEnvironment(env),+ });+ if (result.signal || result.code !== 0) {+ throw new Error(+ `macOS GPUI bundling failed with ${result.signal ?? result.code}`,+ );+ }+ return;+ }++ run("bun", ["run", ...bundleArguments(target, bundleArgs)], {+ cwd: desktopDirectory,+ env: bundleEnvironment({ ...env, RUST_TARGET_TRIPLE: target }),+ });+}++if (+ process.argv[1] &&+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)+) {+ const [target, ...args] = process.argv.slice(2);+ bundleGpui(target, args).catch((error) => {+ console.error(error?.message ?? error);+ process.exitCode = 1;+ });+}diff --git a/scripts/bundle-gpui.test.mjs b/scripts/bundle-gpui.test.mjsnew file mode 100644index 000000000..ca6aea55b--- /dev/null+++ b/scripts/bundle-gpui.test.mjs@@ -0,0 +1,165 @@+import assert from "node:assert/strict";+import { existsSync, readFileSync } from "node:fs";+import path from "node:path";+import test from "node:test";+import {+ bundleArguments,+ bundleEnvironment,+ gpuiBinaryPath,+ gpuiDirectory,+ gpuiPlatformConfig,+ mainBinaryName,+ parseOptions,+ targetPlatform,+} from "./bundle-gpui.mjs";++const readJson = (relative) =>+ JSON.parse(readFileSync(new URL(relative, import.meta.url), "utf8"));++const gpuiConfig = readJson("../apps/desktop-gpui/tauri.conf.json");+const classicConfig = readJson("../apps/desktop/src-tauri/tauri.conf.json");+const classicProduction = readJson(+ "../apps/desktop/src-tauri/tauri.prod.conf.json",+);++test("targets map to their packaging platform and main binary", () => {+ assert.equal(targetPlatform("aarch64-apple-darwin"), "darwin");+ assert.equal(targetPlatform("x86_64-pc-windows-msvc"), "win32");+ assert.equal(targetPlatform("x86_64-unknown-linux-gnu"), "linux");+ assert.equal(targetPlatform("wasm32-unknown-unknown"), null);+ assert.equal(mainBinaryName("x86_64-pc-windows-msvc"), "Cap.exe");+ assert.equal(mainBinaryName("aarch64-apple-darwin"), "Cap");+ assert.equal(+ gpuiBinaryPath("x86_64-pc-windows-msvc"),+ path.join(+ gpuiDirectory,+ "target/x86_64-pc-windows-msvc/release/cap-gpui.exe",+ ),+ );+});++test("the GPUI app keeps the identity every existing install updates into", () => {+ assert.equal(gpuiConfig.productName, "Cap");+ assert.equal(gpuiConfig.mainBinaryName, "Cap");+ assert.equal(gpuiConfig.identifier, "so.cap.desktop");+ assert.equal(+ gpuiConfig.plugins.updater.pubkey,+ classicProduction.plugins.updater.pubkey,+ );+ assert.deepEqual(gpuiConfig.plugins.updater.endpoints, [+ "https://cdn.crabnebula.app/update/cap/cap/{{target}}/{{current_version}}",+ ]);+ const installer = readFileSync(+ new URL("../apps/desktop-gpui/src/installer.rs", import.meta.url),+ "utf8",+ );+ assert.match(+ installer,+ new RegExp(+ `const UPDATER_PUBLIC_KEY: &str = "${gpuiConfig.plugins.updater.pubkey}";`,+ ),+ );+ assert.deepEqual(+ gpuiConfig.plugins["deep-link"],+ classicConfig.plugins["deep-link"],+ );+ assert.equal(gpuiConfig.bundle.createUpdaterArtifacts, true);+});++test("Cap Classic is a separate app that shares Cap's data identity", () => {+ assert.equal(classicProduction.productName, "Cap Classic");+ assert.equal(classicProduction.mainBinaryName, "Cap Classic");+ assert.equal(classicProduction.identifier, gpuiConfig.identifier);+ assert.ok(+ !classicConfig.bundle.externalBin.some((binary) =>+ binary.includes("cap-gpui"),+ ),+ );+ assert.notEqual(+ classicProduction.bundle.fileAssociations[0].name,+ gpuiConfig.bundle.fileAssociations[0].name,+ );+});++test("every committed file the GPUI bundle references exists", () => {+ const files = [+ ...gpuiConfig.bundle.icon,+ gpuiConfig.bundle.macOS.entitlements,+ gpuiConfig.bundle.macOS.dmg.background,+ gpuiConfig.bundle.windows.nsis.headerImage,+ gpuiConfig.bundle.windows.nsis.sidebarImage,+ gpuiConfig.bundle.windows.nsis.installerIcon,+ gpuiConfig.bundle.windows.nsis.installerHooks,+ "Info.plist",+ ];+ for (const file of files) {+ assert.ok(existsSync(path.join(gpuiDirectory, file)), file);+ }+ for (const source of Object.keys(gpuiConfig.bundle.resources)) {+ assert.ok(+ existsSync(path.join(gpuiDirectory, path.dirname(source))),+ source,+ );+ }+ for (const binary of gpuiConfig.bundle.externalBin) {+ assert.ok(+ existsSync(path.join(gpuiDirectory, path.dirname(binary))),+ binary,+ );+ }+});++test("the GPUI bundle ships one CLI sidecar instead of two identical copies", () => {+ const names = gpuiConfig.bundle.externalBin.map((binary) =>+ path.basename(binary),+ );+ assert.deepEqual(names, ["cap-muxer", "cap-cli"]);+ assert.equal(gpuiConfig.bundle.windows.webviewInstallMode.type, "skip");+ assert.ok(+ !Object.values(gpuiConfig.bundle.resources).some((destination) =>+ destination.includes("rive"),+ ),+ );+});++test("platform resources point at the shared native dependencies", () => {+ assert.deepEqual(gpuiPlatformConfig("darwin"), {+ bundle: {+ resources: {+ "../../target/native-deps/onnxruntime/lib/libonnxruntime.dylib":+ "onnxruntime/lib/libonnxruntime.dylib",+ },+ },+ });+ const windows = gpuiPlatformConfig("win32").bundle.resources;+ assert.equal(windows["../../target/ffmpeg/bin/*.dll"], "./");+ assert.equal(windows["../../target/native-deps/onnxruntime/lib/*.dll"], "./");+ assert.equal(gpuiPlatformConfig("linux"), null);+});++test("tauri bundle runs against the GPUI crate with its pinned toolchain", () => {+ assert.deepEqual(bundleArguments("x86_64-unknown-linux-gnu", ["--verbose"]), [+ "tauri",+ "bundle",+ "--target",+ "x86_64-unknown-linux-gnu",+ "--verbose",+ ]);+ const environment = bundleEnvironment({ PATH: "/bin" });+ assert.equal(environment.PATH, "/bin");+ assert.equal(environment.TAURI_APP_PATH, gpuiDirectory);+ assert.match(environment.RUSTUP_TOOLCHAIN, /^\d+\.\d+\.\d+$/);+});++test("signing builds can stop before bundling and rebundle without rebuilding", () => {+ assert.deepEqual(parseOptions(["--no-bundle"]), {+ skipBuild: false,+ noBundle: true,+ bundleArgs: [],+ });+ assert.deepEqual(parseOptions(["--skip-build", "--bundles", "nsis"]), {+ skipBuild: true,+ noBundle: false,+ bundleArgs: ["--bundles", "nsis"],+ });+});diff --git a/scripts/linux-bundle-config.mjs b/scripts/linux-bundle-config.mjsindex 1564f3628..f258fd4d0 100644--- a/scripts/linux-bundle-config.mjs+++ b/scripts/linux-bundle-config.mjs@@ -4,15 +4,54 @@ export function supportedLinuxBundles(version) {: ["deb", "rpm", "appimage"];}+export function supportedLinuxClassicBundles() {+ return ["appimage"];+}++export const CLASSIC_RPM_DEPENDS = [+ "webkit2gtk4.1",+ "gtk3",+ "libayatana-appindicator-gtk3",+ "libva",+ "pulseaudio-utils",+ "pipewire-libs",+ "alsa-lib",+ "alsa-plugins-pulseaudio",+ "libxkbcommon",+ "libxkbcommon-x11",+ "openssl-libs",+];++export const GPUI_RPM_DEPENDS = [+ "libva",+ "pulseaudio-utils",+ "pipewire-libs",+ "alsa-lib",+ "alsa-plugins-pulseaudio",+ "libxkbcommon",+ "libxkbcommon-x11",+ "libX11",+ "openssl-libs",+ "libwayland-client",+ "libwayland-egl",+ "libglvnd-egl",+ "vulkan-loader",+];+export function createLinuxBundleConfig(libraryNames,commonFiles = {},debDependencies = [],+ {+ root = "../../..",+ rpmDependencies = CLASSIC_RPM_DEPENDS,+ mediaFramework = true,+ } = {},) {const files = { ...commonFiles };for (const name of [...new Set(libraryNames)].toSorted()) {files[`/usr/lib/cap/${name}`] =- `../../../target/native-deps/cap-deb-libs/${name}`;+ `${root}/target/native-deps/cap-deb-libs/${name}`;}return {@@ -22,39 +61,25 @@ export function createLinuxBundleConfig(depends: [...new Set([...debDependencies, "libasound2-plugins"])],files: {...files,- "/usr/lib/cap/package-format": "../../../packaging/linux/deb",+ "/usr/lib/cap/package-format": `${root}/packaging/linux/deb`,},},rpm: {compression: { type: "zstd", level: 9 },- depends: [- "webkit2gtk4.1",- "gtk3",- "libayatana-appindicator-gtk3",- "libva",- "pulseaudio-utils",- "pipewire-libs",- "alsa-lib",- "alsa-plugins-pulseaudio",- "libxkbcommon",- "libxkbcommon-x11",- "openssl-libs",- ],+ depends: [...rpmDependencies],files: {...files,- "/usr/lib/cap/package-format": "../../../packaging/linux/rpm",+ "/usr/lib/cap/package-format": `${root}/packaging/linux/rpm`,},},appimage: {- bundleMediaFramework: true,+ bundleMediaFramework: mediaFramework,files: {...files,"/usr/bin/pactl": "/usr/bin/pactl",- "/usr/lib/alsa-lib/libasound_module_pcm_pulse.so":- "../../../target/native-deps/cap-appimage-libs/libasound_module_pcm_pulse.so",- "/usr/lib/cap/alsa-pulse.conf":- "../../../packaging/linux/alsa-pulse.conf",- "/usr/lib/cap/package-format": "../../../packaging/linux/appimage",+ "/usr/lib/alsa-lib/libasound_module_pcm_pulse.so": `${root}/target/native-deps/cap-appimage-libs/libasound_module_pcm_pulse.so`,+ "/usr/lib/cap/alsa-pulse.conf": `${root}/packaging/linux/alsa-pulse.conf`,+ "/usr/lib/cap/package-format": `${root}/packaging/linux/appimage`,},},},diff --git a/scripts/linux-bundle-config.test.mjs b/scripts/linux-bundle-config.test.mjsindex 53f5c133d..9778ff7a8 100644--- a/scripts/linux-bundle-config.test.mjs+++ b/scripts/linux-bundle-config.test.mjs@@ -1,8 +1,11 @@import assert from "node:assert/strict";import { test } from "node:test";import {+ CLASSIC_RPM_DEPENDS,createLinuxBundleConfig,+ GPUI_RPM_DEPENDS,supportedLinuxBundles,+ supportedLinuxClassicBundles,} from "./linux-bundle-config.mjs";test("nightly builds retain DEB and AppImage without passing invalid hyphenated versions to RPM", () => {@@ -76,3 +79,43 @@ test("Debian audio dependencies retain existing requirements without duplicates"["libgtk-3-0", "libasound2-plugins"],);});++test("the GPUI app maps native libraries from its own crate directory without webview packages", () => {+ const config = createLinuxBundleConfig(+ ["libavcodec.so.61"],+ {},+ ["libxkbcommon0"],+ {+ root: "../..",+ rpmDependencies: GPUI_RPM_DEPENDS,+ mediaFramework: false,+ },+ );+ const { appimage, deb, rpm } = config.bundle.linux;+ for (const format of [appimage, deb, rpm]) {+ assert.equal(+ format.files["/usr/lib/cap/libavcodec.so.61"],+ "../../target/native-deps/cap-deb-libs/libavcodec.so.61",+ );+ }+ assert.equal(+ deb.files["/usr/lib/cap/package-format"],+ "../../packaging/linux/deb",+ );+ assert.equal(appimage.bundleMediaFramework, false);+ assert.deepEqual(deb.depends, ["libxkbcommon0", "libasound2-plugins"]);+ for (const depends of [deb.depends, rpm.depends]) {+ assert.ok(+ !depends.some((dependency) => /webkit|gtk|appindicator/.test(dependency)),+ );+ }+ assert.notEqual(rpm.depends, GPUI_RPM_DEPENDS);+});++test("Cap Classic ships on Linux as a self-contained AppImage", () => {+ assert.deepEqual(supportedLinuxClassicBundles(), ["appimage"]);+ assert.deepEqual(+ createLinuxBundleConfig([]).bundle.linux.rpm.depends,+ CLASSIC_RPM_DEPENDS,+ );+});diff --git a/scripts/run-gpui-build.mjs b/scripts/run-gpui-build.mjsdeleted file mode 100644index ac751cc65..000000000--- a/scripts/run-gpui-build.mjs+++ /dev/null@@ -1,91 +0,0 @@-import { spawnSync } from "node:child_process";-import { existsSync } from "node:fs";-import * as path from "node:path";-import { fileURLToPath } from "node:url";--export function shouldBuildGpui(- platform,- environment,- profile,- developmentWorkspaceAvailable = true,-) {- if (!["darwin", "win32", "linux"].includes(platform)) return false;- if (profile === "release") return true;- return (- platform === "darwin" &&- environment.CAP_GPUI_DEV !== "0" &&- developmentWorkspaceAvailable- );-}--export function shouldBundleGpui(- platform,- environment,- profile,- stagedSidecarAvailable,- developmentWorkspaceAvailable = true,-) {- return (- shouldBuildGpui(- platform,- environment,- profile,- developmentWorkspaceAvailable,- ) &&- (profile === "release" || stagedSidecarAvailable)- );-}--function main() {- const profile = process.argv[2];- if (profile !== "debug" && profile !== "release") {- console.error("The Cap GPUI build profile must be debug or release.");- process.exitCode = 1;- return;- }-- const scriptsDir = path.dirname(fileURLToPath(import.meta.url));- const gpuiDevScript = path.join(- scriptsDir,- "..",- "apps",- "desktop-gpui",- "dev.sh",- );-- if (- !shouldBuildGpui(- process.platform,- process.env,- profile,- profile !== "debug" || existsSync(gpuiDevScript),- )- ) {- console.log(- `Skipping Cap GPUI ${profile} build on ${process.platform}${- process.env.CAP_GPUI_DEV === "0" ? " because CAP_GPUI_DEV=0" : ""- }.`,- );- return;- }-- const result = spawnSync(- "bash",- [path.join(scriptsDir, "build-gpui-binary.sh"), profile],- { stdio: "inherit" },- );-- if (result.error) {- console.error(`Failed to build Cap GPUI: ${result.error.message}`);- process.exitCode = 1;- } else if (result.status !== 0) {- process.exitCode = result.status ?? 1;- }-}--if (- process.argv[1] &&- path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)-) {- main();-}diff --git a/scripts/run-gpui-build.test.mjs b/scripts/run-gpui-build.test.mjsdeleted file mode 100644index 2121a395d..000000000--- a/scripts/run-gpui-build.test.mjs+++ /dev/null@@ -1,50 +0,0 @@-import assert from "node:assert/strict";-import test from "node:test";-import { shouldBuildGpui, shouldBundleGpui } from "./run-gpui-build.mjs";--test("GPUI release builds run on every supported desktop platform", () => {- assert.equal(shouldBuildGpui("darwin", {}, "release"), true);- assert.equal(shouldBuildGpui("win32", {}, "release"), true);- assert.equal(shouldBuildGpui("linux", {}, "release"), true);- assert.equal(shouldBuildGpui("freebsd", {}, "release"), false);-});--test("GPUI development builds honor their platform and opt-out guards", () => {- assert.equal(shouldBuildGpui("darwin", {}, "debug"), true);- assert.equal(- shouldBuildGpui("darwin", { CAP_GPUI_DEV: "0" }, "debug"),- false,- );- assert.equal(shouldBuildGpui("darwin", {}, "debug", false), false);- assert.equal(shouldBuildGpui("win32", {}, "debug"), false);- assert.equal(shouldBuildGpui("linux", {}, "debug"), false);-});--test("the development opt-out never suppresses supported release builds", () => {- for (const platform of ["darwin", "win32", "linux"]) {- assert.equal(- shouldBuildGpui(platform, { CAP_GPUI_DEV: "0" }, "release"),- true,- );- }-});--test("macOS development only bundles an enabled and available GPUI sidecar", () => {- assert.equal(shouldBundleGpui("darwin", {}, "debug", true), true);- assert.equal(shouldBundleGpui("darwin", {}, "debug", false), false);- assert.equal(shouldBundleGpui("darwin", {}, "debug", true, false), false);- assert.equal(- shouldBundleGpui("darwin", { CAP_GPUI_DEV: "0" }, "debug", true),- false,- );-});--test("release bundling is mandatory on every supported desktop platform", () => {- for (const platform of ["darwin", "win32", "linux"]) {- assert.equal(- shouldBundleGpui(platform, { CAP_GPUI_DEV: "0" }, "release", false),- true,- );- }- assert.equal(shouldBundleGpui("freebsd", {}, "release", true), false);-});diff --git a/scripts/setup.js b/scripts/setup.jsindex 4692a8dcf..72ff88910 100644--- a/scripts/setup.js+++ b/scripts/setup.js@@ -7,7 +7,10 @@ import * as path from "node:path";import { env } from "node:process";import { fileURLToPath } from "node:url";import { promisify } from "node:util";-import { createLinuxBundleConfig } from "./linux-bundle-config.mjs";+import {+ createLinuxBundleConfig,+ GPUI_RPM_DEPENDS,+} from "./linux-bundle-config.mjs";const exec = promisify(execCb);const execFile = promisify(execFileCb);@@ -737,28 +740,43 @@ async function writeLinuxTauriConfig(sonameLibs) {await fs.mkdir(appimageLibDir, { recursive: true });await fs.copyFile(pulsePlugin, path.join(appimageLibDir, pluginName));- const configPath = path.join(- __root,- "apps",- "desktop",- "src-tauri",- "tauri.linux.conf.json",- );- const baseConfig = JSON.parse(- await fs.readFile(- path.join(path.dirname(configPath), "tauri.conf.json"),- "utf8",- ),+ const classicDirectory = path.join(__root, "apps", "desktop", "src-tauri");+ const classicConfig = JSON.parse(+ await fs.readFile(path.join(classicDirectory, "tauri.conf.json"), "utf8"),);- const config = createLinuxBundleConfig(- sonameLibs,- baseConfig.bundle.linux.deb.files,- baseConfig.bundle.linux.deb.depends,+ await writeFileIfChanged(+ path.join(classicDirectory, "tauri.linux.conf.json"),+ `${JSON.stringify(+ createLinuxBundleConfig(+ sonameLibs,+ classicConfig.bundle.linux.deb.files,+ classicConfig.bundle.linux.deb.depends,+ ),+ null,+ "\t",+ )}\n`,);+ const gpuiDirectory = path.join(__root, "apps", "desktop-gpui");+ const gpuiConfig = JSON.parse(+ await fs.readFile(path.join(gpuiDirectory, "tauri.conf.json"), "utf8"),+ );await writeFileIfChanged(- configPath,- `${JSON.stringify(config, null, "\t")}\n`,+ path.join(gpuiDirectory, "tauri.linux.conf.json"),+ `${JSON.stringify(+ createLinuxBundleConfig(+ sonameLibs,+ {},+ gpuiConfig.bundle.linux.deb.depends,+ {+ root: "../..",+ rpmDependencies: GPUI_RPM_DEPENDS,+ mediaFramework: false,+ },+ ),+ null,+ "\t",+ )}\n`,);console.log(`Generated Linux Tauri package configs with ${sonameLibs.length} shared libraries`,diff --git a/scripts/verify-gpui-release-inputs.mjs b/scripts/verify-gpui-release-inputs.mjsdeleted file mode 100644index 8db35f432..000000000--- a/scripts/verify-gpui-release-inputs.mjs+++ /dev/null@@ -1,78 +0,0 @@-import { execFileSync } from "node:child_process";-import { createHash } from "node:crypto";-import * as fs from "node:fs/promises";-import * as path from "node:path";-import { fileURLToPath } from "node:url";--const repoRoot = path.resolve(- path.dirname(fileURLToPath(import.meta.url)),- "..",-);--const configNames = {- darwin: "tauri.macos.conf.json",- win32: "tauri.windows.conf.json",- linux: "tauri.linux.conf.json",-};-const configName = configNames[process.platform];--if (!configName) {- console.log(`Skipping Cap GPUI release validation on ${process.platform}.`);-} else {- const srcTauri = path.join(repoRoot, "apps/desktop/src-tauri");- const configPath = path.join(srcTauri, configName);- const productionConfigPath = path.join(srcTauri, "tauri.prod.conf.json");- const [config, productionConfig] = await Promise.all([- fs.readFile(configPath, "utf8").then(JSON.parse),- fs.readFile(productionConfigPath, "utf8").then(JSON.parse),- ]);- const externalBin =- productionConfig.bundle?.externalBin ?? config.bundle?.externalBin;- if (- !Array.isArray(externalBin) ||- !externalBin.includes("binaries/cap-gpui")- ) {- throw new Error(- `The effective ${process.platform} release config does not bundle Cap GPUI.`,- );- }-- const binariesDir = path.join(srcTauri, "binaries");- const requestedTarget = process.env.RUST_TARGET_TRIPLE;- const host = execFileSync("rustc", ["-vV"], { encoding: "utf8" }).match(- /^host:\s*(.+)$/m,- )?.[1];- const target = requestedTarget ?? host;- if (!target) throw new Error("Could not determine the Rust target triple");-- const extension = process.platform === "win32" ? ".exe" : "";- const fileName = `cap-gpui-${target}${extension}`;- const binaryPath = path.join(binariesDir, fileName);- const releaseBinaryPath = path.join(- repoRoot,- "apps",- "desktop-gpui",- "target",- ...(requestedTarget ? [target] : []),- "release",- `cap-gpui${extension}`,- );- const [stagedBinary, releaseBinary] = await Promise.all([- fs.readFile(binaryPath),- fs.readFile(releaseBinaryPath),- ]);-- if (stagedBinary.length === 0 || releaseBinary.length === 0) {- throw new Error("The staged Cap GPUI release binary is empty");- }-- const sha256 = (contents) =>- createHash("sha256").update(contents).digest("hex");- if (sha256(stagedBinary) !== sha256(releaseBinary)) {- throw new Error(`${binaryPath} does not match ${releaseBinaryPath}`);- }-- console.log(- `Verified effective ${process.platform} release configuration and ${fileName} for GPUI packaging.`,- );-}diff --git a/scripts/windows-release-signing.ps1 b/scripts/windows-release-signing.ps1index 467cd65a2..3d712412b 100644--- a/scripts/windows-release-signing.ps1+++ b/scripts/windows-release-signing.ps1@@ -1,11 +1,13 @@[CmdletBinding()]param([Parameter(Mandatory = $true)]- [ValidateSet("Stage", "Restore", "VerifyInstaller")]+ [ValidateSet("Stage", "Restore", "StageInstallers", "RestoreInstallers", "VerifyInstaller")][string] $Operation,[string] $Target = $env:RUST_TARGET_TRIPLE,[string] $WorkspaceRoot = $env:GITHUB_WORKSPACE,- [string] $InstallerPath+ [string] $InstallerPath,+ [ValidateSet("cap", "classic")]+ [string] $App)Set-StrictMode -Version Latest@@ -21,31 +23,43 @@ if ([string]::IsNullOrWhiteSpace($Target)) {}$releaseRoot = Join-Path $WorkspaceRoot "target/$Target/release"+$gpuiReleaseRoot = Join-Path $WorkspaceRoot "apps/desktop-gpui/target/$Target/release"+$sidecarRoot = Join-Path $WorkspaceRoot "apps/desktop/src-tauri/binaries"$signingRoot = Join-Path $releaseRoot "windows-signing"$payloadRoot = Join-Path $signingRoot "payload"+$installerRoot = Join-Path $signingRoot "installers"$manifestPath = Join-Path $signingRoot "payload-manifest.json"+$installerBundleRoots = @(+ (Join-Path $gpuiReleaseRoot "bundle/nsis"),+ (Join-Path $releaseRoot "bundle/nsis")+)function Get-PayloadDefinitions {return @([pscustomobject]@{Name = "Cap.exe"- Path = Join-Path $releaseRoot "Cap.exe"+ Path = Join-Path $gpuiReleaseRoot "cap-gpui.exe"+ Apps = @("cap")},[pscustomobject]@{- Name = "cap-gpui.exe"- Path = Join-Path $WorkspaceRoot "apps/desktop/src-tauri/binaries/cap-gpui-$Target.exe"+ Name = "Cap Classic.exe"+ Path = Join-Path $releaseRoot "Cap Classic.exe"+ Apps = @("classic")},[pscustomobject]@{Name = "cap-cli.exe"- Path = Join-Path $WorkspaceRoot "apps/desktop/src-tauri/binaries/cap-cli-$Target.exe"+ Path = Join-Path $sidecarRoot "cap-cli-$Target.exe"+ Apps = @("cap", "classic")},[pscustomobject]@{Name = "cap-exporter.exe"- Path = Join-Path $WorkspaceRoot "apps/desktop/src-tauri/binaries/cap-exporter-$Target.exe"+ Path = Join-Path $sidecarRoot "cap-exporter-$Target.exe"+ Apps = @("classic")},[pscustomobject]@{Name = "cap-muxer.exe"- Path = Join-Path $WorkspaceRoot "apps/desktop/src-tauri/binaries/cap-muxer-$Target.exe"+ Path = Join-Path $sidecarRoot "cap-muxer-$Target.exe"+ Apps = @("cap", "classic")})}@@ -76,10 +90,10 @@ function Read-Manifest {throw "Payload manifest '$manifestPath' does not exist."}$manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json- if ($manifest.schemaVersion -ne 1 -or $manifest.target -ne $Target -or @($manifest.entries).Count -ne 5) {+ $expectedNames = @(Get-PayloadDefinitions | ForEach-Object Name | Sort-Object)+ if ($manifest.schemaVersion -ne 2 -or $manifest.target -ne $Target -or @($manifest.entries).Count -ne $expectedNames.Count) {throw "Payload manifest '$manifestPath' has an unexpected schema."}- $expectedNames = @(Get-PayloadDefinitions | ForEach-Object Name | Sort-Object)$actualNames = @($manifest.entries | ForEach-Object name | Sort-Object)if (Compare-Object $expectedNames $actualNames) {throw "Payload manifest '$manifestPath' has unexpected executable names."@@ -103,6 +117,15 @@ function Assert-Authenticode([string] $Path) {return $signature}+function Get-BundledInstallers {+ $installers = @(foreach ($root in $installerBundleRoots) {+ if (Test-Path -LiteralPath $root -PathType Container) {+ Get-ChildItem -LiteralPath $root -Filter *.exe -File+ }+ })+ return $installers+}+function Stage-Payload {if (Test-Path -LiteralPath $signingRoot) {Remove-Item -LiteralPath $signingRoot -Recurse -Force@@ -116,6 +139,7 @@ function Stage-Payload {$null = Copy-Item -LiteralPath $definition.Path -Destination $destination -Force -PassThru[ordered]@{name = $definition.Name+ apps = @($definition.Apps)bytes = (Get-Item -LiteralPath $definition.Path).LengthpreSignSha256 = Get-Sha256 $definition.PathsignedSha256 = $null@@ -125,9 +149,10 @@ function Stage-Payload {}}Write-Manifest ([ordered]@{- schemaVersion = 1+ schemaVersion = 2target = $Targetentries = @($entries)+ installers = @()verifiedInstallers = @()})Write-Host "Staged $($entries.Count) first-party Windows payload executables."@@ -158,9 +183,57 @@ function Restore-Payload {Write-Host "Restored and Authenticode-verified signed Windows payload executables."}+function Stage-Installers {+ $manifest = Read-Manifest+ if (Test-Path -LiteralPath $installerRoot) {+ Remove-Item -LiteralPath $installerRoot -Recurse -Force+ }+ $null = New-Item -ItemType Directory -Path $installerRoot -Force+ $installers = @(Get-BundledInstallers)+ if ($installers.Count -ne 2) {+ throw "Expected the Cap and Cap Classic installers, found $($installers.Count)."+ }+ $staged = foreach ($installer in $installers) {+ $destination = Join-Path $installerRoot $installer.Name+ if (Test-Path -LiteralPath $destination) {+ throw "Two installers are both named '$($installer.Name)'."+ }+ $null = Copy-Item -LiteralPath $installer.FullName -Destination $destination -PassThru+ [ordered]@{+ name = $installer.Name+ path = $installer.FullName+ preSignSha256 = Get-Sha256 $installer.FullName+ }+ }+ $manifest.installers = @($staged)+ Write-Manifest $manifest+ Write-Host "Staged $($staged.Count) Windows installers for Authenticode signing."+}++function Restore-Installers {+ $manifest = Read-Manifest+ $signedRoot = Join-Path $WorkspaceRoot "signed-windows-installer"+ if (-not (Test-Path -LiteralPath $signedRoot -PathType Container)) {+ throw "Signed installer directory '$signedRoot' does not exist."+ }+ if (@($manifest.installers).Count -ne 2) {+ throw "No staged installers are recorded in '$manifestPath'."+ }+ foreach ($installer in $manifest.installers) {+ if ((Get-Sha256 $installer.path) -ne $installer.preSignSha256) {+ throw "Unsigned installer '$($installer.name)' changed after staging."+ }+ $signedFile = Find-UniqueFile $signedRoot $installer.name+ $null = Assert-Authenticode $signedFile.FullName+ $null = Copy-Item -LiteralPath $signedFile.FullName -Destination $installer.path -Force -PassThru+ $null = Assert-Authenticode $installer.path+ }+ Write-Host "Restored and Authenticode-verified the signed Windows installers."+}+function Verify-Installer {- if ([string]::IsNullOrWhiteSpace($InstallerPath)) {- throw "-InstallerPath is required for VerifyInstaller."+ if ([string]::IsNullOrWhiteSpace($InstallerPath) -or [string]::IsNullOrWhiteSpace($App)) {+ throw "-InstallerPath and -App are required for VerifyInstaller."}$installer = (Resolve-Path -LiteralPath $InstallerPath).Path$installerSignature = Assert-Authenticode $installer@@ -177,24 +250,35 @@ function Verify-Installer {throw "Could not extract Windows installer '$installer'."}foreach ($entry in $manifest.entries) {+ $included = @($entry.apps) -contains $App+ $extracted = @(Get-ChildItem -LiteralPath $extractRoot -Recurse -File | Where-Object Name -eq $entry.name)+ if (-not $included) {+ if ($extracted.Count -ne 0) {+ throw "The $App installer unexpectedly contains '$($entry.name)'."+ }+ continue+ }if ([string]::IsNullOrWhiteSpace($entry.signedSha256)) {throw "Manifest entry '$($entry.name)' has no signed hash."}- $extracted = Find-UniqueFile $extractRoot $entry.name- $signature = Assert-Authenticode $extracted.FullName- $actualHash = Get-Sha256 $extracted.FullName+ if ($extracted.Count -ne 1) {+ throw "Expected exactly one '$($entry.name)' in the $App installer, found $($extracted.Count)."+ }+ $signature = Assert-Authenticode $extracted[0].FullName+ $actualHash = Get-Sha256 $extracted[0].FullNameif ($actualHash -ne $entry.signedSha256 -or $signature.SignerCertificate.Thumbprint -ne $entry.signerThumbprint) {throw "Installer payload '$($entry.name)' hash differs from the signed payload manifest."}}$manifest.verifiedInstallers = @($manifest.verifiedInstallers) + @([ordered]@{+ app = $Appname = [System.IO.Path]::GetFileName($installer)sha256 = Get-Sha256 $installersignerThumbprint = $installerSignature.SignerCertificate.ThumbprintsignerSubject = $installerSignature.SignerCertificate.Subject})Write-Manifest $manifest- Write-Host "Verified installer Authenticode and signed payload hashes."+ Write-Host "Verified the $App installer's Authenticode and signed payload hashes."}finally {if (Test-Path -LiteralPath $extractRoot) {@@ -206,5 +290,7 @@ function Verify-Installer {switch ($Operation) {"Stage" { Stage-Payload }"Restore" { Restore-Payload }+ "StageInstallers" { Stage-Installers }+ "RestoreInstallers" { Restore-Installers }"VerifyInstaller" { Verify-Installer }}