name: Build Electron App

on:
    push:
        tags:
            - 'v*'

jobs:
    build:
        strategy:
            fail-fast: false
            matrix:
                include:
                    - os: windows-latest
                      script: build:win
                    - os: macos-latest
                      script: build:mac
                    - os: ubuntu-latest
                      script: build:linux

        runs-on: ${{ matrix.os }}

        steps:
            - name: Checkout repository
              uses: actions/checkout@v4

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

            - name: Install dependencies
              run: npm ci

            - name: Run platform build
              run: npm run ${{ matrix.script }}
              env:
                  CSC_LINK: ${{ secrets.CSC_LINK }}
                  CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}

            - name: Upload artifacts
              uses: actions/upload-artifact@v4
              with:
                  name: ${{ matrix.os }}-build
                  path: |
                      dist/**
