name: Build Electron Windows App

on:
  push:
    branches:
      - main
      - master
    paths:
      - 'windows-app/**'
      - '.github/workflows/build-electron-app.yml'
  workflow_dispatch:

permissions:
  contents: read
  actions: write

jobs:
  build-windows:
    name: Build Electron App (Windows)
    runs-on: windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install dependencies
        run: npm install
        working-directory: windows-app

      - name: Build Electron app
        run: npm run build:win -- --publish never
        working-directory: windows-app
        env:
          BACKEND_BASE_URL: ${{ secrets.BACKEND_BASE_URL }}

      - name: Upload Windows artifact
        uses: actions/upload-artifact@v4
        with:
          name: plugin-compass-electron-windows
          path: windows-app/dist/*.exe
          retention-days: 7
