name: Release desktop app (manual backup)

# Self-hosted updates run from scripts/release.mjs on Dennis's Windows box.
# This workflow is kept as a manual backup — trigger it from the Actions tab
# if the local build host is unavailable.

on:
  workflow_dispatch:
    inputs:
      tag:
        description: "Tag to build (e.g. v0.10.2) — must already exist"
        required: true

permissions:
  contents: write

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ inputs.tag }}

      - name: Install pnpm
        uses: pnpm/action-setup@v4

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: pnpm

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Install JS deps
        run: pnpm install --frozen-lockfile

      - name: Build desktop app
        uses: tauri-apps/tauri-action@v0
        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 }}
          VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }}
          VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }}
          VITE_AUTH_REDIRECT_URL: ${{ secrets.VITE_AUTH_REDIRECT_URL }}
          VITE_LIVEKIT_URL: ${{ secrets.VITE_LIVEKIT_URL }}
        with:
          projectPath: apps/desktop
          tagName: ${{ inputs.tag }}
          releaseName: "ChatApp ${{ inputs.tag }}"
          releaseBody: "Manual build — copy .nsis.zip/.sig/latest.json to the update host."
          releaseDraft: true
          prerelease: false
          tauriScript: pnpm exec tauri
          args: "--bundles nsis"
