name: Build and Deploy Stable Release

on: 
  push:
    tags:
      - v*
  workflow_dispatch :
permissions:
  contents: write
 
jobs:
  # --- JOB 1 : NUITKA COMPILATION (Windows/Linux) ---
  build:
    name: Build Nuitka Binaries
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: actions/setup-python@v6.2.0
        with:
          python-version: "3.12"
          cache: 'pip'
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install . nuitka
      - name: Build with Nuitka
        run: hatch run python -m nuitka --standalone --assume-yes-for-download --output-dir=dist src/lce_qt_launcher/main.py
      
      - name: Package Windows
        if: matrix.os == 'windows-latest'
        shell: pwsh
        run: Compress-Archive -Path dist\main.dist\* -DestinationPath LCE-Qt-Launcher-Windows.zip

      - name: Package Linux
        if: matrix.os == 'ubuntu-latest'
        run: tar -czf LCE-Qt-Launcher-Linux.tar.gz -C dist/main.dist .

      - name: Upload Artifact
        uses: actions/upload-artifact@v7.0.1
        with:
          name: binaries-${{ matrix.os }}
          path: |
            *.zip
            *.tar.gz

  # --- JOB 2 : Building Windows Installer ---
  build_windows_installer:
    name: Build Inno Setup
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v6.0.2
      - name: Compile .ISS
        uses: Minionguyjpro/Inno-Setup-Action@v1.2.8
        with:
          path: packages\windows\stable.iss

      - name: Upload Artifact
        uses: actions/upload-artifact@v7.0.1
        with:
          name: installer-windows
          path: packages\windows\Output\*.exe 

    # FIXME : both the appimage and arch packages action

    # TODO : Add a upload to a release job