name: debian-build

on:
  push:
    paths-ignore:
      - '**.md'
      - 'data/locale/**'
    branches:
      - master
    tags:
      - '*'
  pull_request:
    paths-ignore:
      - '**.md'
      - 'data/locale/**'
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          submodules: "recursive"
      - name: check_libobs_revision
        run: |
          sudo apt update
          sudo apt install devscripts libobs-dev
          mkdir source
          cd source
          dpkg -l libobs-dev | tr -s " "| grep libobs | cut -d" " -f3 > libobs.rev
      - name: create_tarball
        run: |
          cd ..
          tar --exclude=.git -cvzf obs-scene-switcher_0.1+testonly.orig.tar.gz SceneSwitcher
      - name: create_debian_dir
        run: |
          cp -a CI/linux/debian .
      - name: install_dependencies
        run: |
          # devscripts and libobs-dev are needed but they were already installed
          # from check_libobs_revision and install_frontend_header sections.
          sudo apt update
          sudo apt install cmake debhelper libcurl4-openssl-dev libxss-dev libxtst-dev qtbase5-dev libopencv-dev libprocps-dev
      - name: build
        run: |
          debuild --no-lintian --no-sign
          mv ../*.deb .
      - name: Publish
        if: success()
        uses: actions/upload-artifact@v2.2.1
        with:
          name: "obs-scene-switcher.deb"
          path: ${{ github.workspace }}/*.deb
