name: CI/CD

on: [push, pull_request]

jobs:
  linux:
    name: Linux-x86-${{ matrix.compiler }}
    runs-on: node-bookworm
    strategy:
      matrix:
        compiler: [g++, clang++]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      
      - name: Install dependencies
        run: |
          apt update
          apt install -y sudo g++-multilib clang libgl1-mesa-dev
      
      - name: Build
        run: |
          cd linux
          make COMPILER=${{ matrix.compiler }} CFG=release
     
      - name: Package
        run: |
          cp -r linux/release/cl_dlls photomode/cl_dlls
          cp -r linux/release/dlls photomode/dlls

      - name: Deploy
        uses: forgejo/upload-artifact@v4
        with:
          name: Linux-x86-${{ matrix.compiler }}-${{ github.sha }}
          path: photomode/
          if-no-files-found: error

      - name: Release
        uses: actions/forgejo-release@v2
        if: startsWith(github.ref, 'refs/tags/')
        with:
          url: https://code.nullprop.sh
          direction: upload
          release-dir: photomode
          tag: "${{ github.ref_name }}"
          token: ${{ secrets.TOKEN }}
