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@v4
        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 build-aux/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 build-essential cmake debhelper libcurl4-openssl-dev libxss-dev libxtst-dev qt6-base-dev libopencv-dev libproc2-dev
      - name: build
        run: |
          debuild --no-lintian --no-sign
          mv ../*.deb .
      - name: Publish
        if: success()
        uses: actions/upload-artifact@v4
        with:
          name: "obs-scene-switcher.deb"
          path: ${{ github.workspace }}/*.deb
