name: Build EXE and Release
run-name: ${{ gitea.actor }}
on:
  push:
    branches:
    - master
    - RustImplementation

jobs:
  Build and Release:
    runs-on: debian-stable
    env:
      DISPLAY: :99

    steps:
      - name: Install Prerequisites
        run: |
          dpkg --add-architecture i386
          apt update > /dev/null 2>&1
          apt install git curl wine32:i386 xvfb -y > /dev/null 2>&1

      - name: Start X Virtual Framebuffer (Xvfb)
        run: |
          # Start Xvfb in the background using the defined display number
          Xvfb :99 -screen 0 1024x768x16 &

      - name: Cloning Repository
        run: |
          git clone https://brotoskyj:${{ secrets.RUNNER_TOKEN }}@git.racooncity.org/brotoskyj/build_test --branch RustImplementation
          pwd
          ls

      - name: Setting Up Build Environment
        run: |
          apt install wine64 -y -qq > /dev/null 2>&1
          curl -L -o python.exe https://www.python.org/ftp/python/3.13.9/python-3.13.9-amd64.exe
          wine python.exe /quiet /NoWeb InstallAllUsers=1 PrependPath=1 TargetDir=C:/Python313
          cp -r build_test/ ~/.wine/drive_c/Python313/
          cd ~/.wine/drive_c/Python313
          wine python.exe -m pip install nuitka pywin32 keyring --break-system-packages
          wine python.exe -m pip install -r build_test/requirements.txt
          wine python.exe -m pip install \
          --index-url https://git.racooncity.org/api/packages/brotoskyj/pypi/simple/ \
          airlock-libs --break-system-packages

      - name: Build Executable
        env:
          DISPLAY: :99
          WINEDEBUG: -all
        run: |
          xvfb-run -a wine cmd /c nuitka --onefile --onefile-windows-splash-screen-image=build_test/loading.png --follow-imports --include-module=keyring.backends.Windows --include-module=win32cred --include-module=pywintypes --include-module=pythoncom --include-module=win32api --include-module=win32security --include-module=win32con --windows-product-name='LoXide' --windows-product-version='1.2.10.0' --windows-company-name='WVUM IRT' --windows-icon-from-ico=build_test/IRT_icon_32-512.ico build_test/AirlockTools_client.py --deployment --assume-yes-for-downloads