name: Electron

defaults:
  run:
    shell: bash

env:
  CI: true

on:
  push:
    branches:
      - master

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: false

jobs:
  build:
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - windows-latest
          - macos-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - if: ${{ startsWith(matrix.os, 'windows') }}
        run: pip.exe install setuptools
      - if: ${{ ! startsWith(matrix.os, 'windows') }}
        run: python3 -m pip install setuptools
      - name: Set up environment
        uses: ./.github/actions/setup
      - name: Build Electron
        run: ./bin/package-electron
        env:
          CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
          CSC_LINK: ${{ secrets.CSC_LINK }}
          APPLE_ID: ${{ secrets.APPLE_ID }}
          APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
      - name: Upload Build
        uses: actions/upload-artifact@v4
        with:
          name: actual-electron-${{ matrix.os }}
          path: |
            packages/desktop-electron/dist/*.dmg
            packages/desktop-electron/dist/*.exe
            packages/desktop-electron/dist/*.AppImage
