name: Build Debian Packages

on:
  push:
    branches: [ "main" ]
  pull_request:
  workflow_dispatch:

jobs:
  build:
    strategy:
      matrix:
        target: [debian12, debian13]
        include:
          - target: debian12
            codename: bookworm
          - target: debian13
            codename: trixie
    
    runs-on: ${{ matrix.target }}

    steps:
      - name: Install Node.js and git
        run: |
          apt-get update
          apt-get -y install nodejs git lsb-release

      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          github-server-url: https://gitea.pkm.physik.tu-darmstadt.de

      - name: Install build dependencies
        run: |
          bash requirements.debian

      - name: Build Package
        run: |
          dpkg-buildpackage -us -uc -b

      - name: Collect Artifacts
        run: |
          mkdir -p artifacts
          mv -v ../*.deb artifacts/

      - name: Upload Artifacts
        uses: actions/upload-artifact@v3
        with:
          name: python3-damaris-${{ matrix.codename }}.gz
          path: artifacts/*.deb
