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@v2
      - name: Set up environment
        uses: ./.github/actions/setup
      - name: Build API
        run: cd packages/loot-core && yarn build:api

  web:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up environment
        uses: ./.github/actions/setup
      - name: Build Web
        run: ./bin/package-browser

  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@v2
      - name: Set up environment
        uses: ./.github/actions/setup
      - name: Build Electron
        run: ./bin/package
