name: Create Release Package

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch: {}

jobs:
  build-release:
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: Linux
          - os: windows-latest
            target: Windows
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install Linux system dependencies
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y binutils

      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pyinstaller requests

      - name: Build release package with Packagemaker
        run: |
          python packagemaker.py compile . --output ./dist --target ${{ matrix.target }} --headless

      - name: Upload release artifact
        uses: actions/upload-artifact@v4
        with:
          name: release-iflapp-${{ matrix.target }}
          path: dist/*.iflapp
