name: Build

defaults:
  run:
    shell: bash

env:
  CI: true

on:
  push:
    branches:
      - master
  pull_request:
    branches: '*'

jobs:
  api:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up environment
        uses: ./.github/actions/setup
      - name: Build API
        run: cd packages/api && yarn build

  web:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up environment
        uses: ./.github/actions/setup
      - name: Build Web
        run: ./bin/package-browser
      - name: Upload Build
        uses: actions/upload-artifact@v3
        with:
          name: actual-web
          path: packages/desktop-client/build

  # TODO: re-enable after solving https://github.com/actualbudget/actual/issues/468
  # electron:
  #   # As electron builds take longer, we only run them in master.
  #   if: github.event_name != 'pull_request'
  #   strategy:
  #     matrix:
  #       os:
  #         - ubuntu-latest
  #         - windows-latest
  #         - macos-latest
  #   runs-on: ${{ matrix.os }}
  #   steps:
  #     - uses: actions/checkout@v3
  #     - name: Set up environment
  #       uses: ./.github/actions/setup
  #     - name: Build Electron
  #       run: ./bin/package
