name: Automatic build

on:
  push:
    branches:
      - '**'
  pull_request:
    branches:
      - '**'
  release:
    types: [ created ]
env:
  BUILD_TYPE: Release

jobs:
  build:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v2

    - name: Install dependencies
      run: |
        sudo apt update
        sudo apt install qt5-default libqt5gui5 libqt5x11extras5 cmake pkg-config qtbase5-dev libqt5x11extras5-dev qtbase5-private-dev libx11-dev xcb libx11-xcb-dev
        
    - name: Create Build Environment
      run: cmake -E make_directory ${{runner.workspace}}/build 

    - name: Configure CMake
      shell: bash
      working-directory: ${{runner.workspace}}/build
      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_EXAMPLE=true

    - name: Build
      working-directory: ${{runner.workspace}}/build
      shell: bash
      run: make -j2

    - name: Install
      working-directory: ${{runner.workspace}}/build
      shell: bash
      run: sudo make install

    #- name: Test
      #working-directory: ${{runner.workspace}}/build
      #shell: bash
      #run: |
        #cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_EXAMPLE=true -DBUILD_TESTING=true
        #make -j2
        #make test
