# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python compile

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

permissions:
  contents: read

jobs:
  build:

    #runs-on: ubuntu-18.04
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: ['windows-latest', 'ubuntu-20.04', 'macos-latest']
        #os: ['windows-latest']
        py: ['hx']

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python 3.9
      uses: actions/setup-python@v4
      with:
        python-version: "3.9"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip        
        pip install .
        pip install pyinstaller onnxruntime
    - name: Run Pyinstaller 1
      if: matrix.os == 'windows-latest'
      run: |

        #pyinstaller -c –-paths ./tigerhx --icon=./tigerhx/exe/${{ matrix.py }}/ico.ico --add-data "./tigerhx/exe/onnxruntime_providers_shared.dll;onnxruntime/capi" -F ./tigerhx/${{ matrix.py }}.py
        pyinstaller -c -p ./tigerhx --icon=./tigerhx/exe/ico.ico --add-data "./tigerhx/exe/onnxruntime_providers_shared.dll;onnxruntime/capi" -F ./tigerhx/${{ matrix.py }}.py
    - name: Run Pyinstaller  2
      if: matrix.os == 'ubuntu-20.04'
      run: |
        pyinstaller -c -p ./tigerhx --icon=./tigerhx/exe/ico.ico --add-data ./tigerhx/exe/libonnxruntime_providers_shared.so:onnxruntime/capi -F ./tigerhx/${{ matrix.py }}.py
    - name: Run Pyinstaller 3
      if: matrix.os == 'macos-latest'
      run: |
        pyinstaller -c -p ./tigerhx --icon=./tigerhx/exe/ico.ico --add-data ./tigerhx/exe/libonnxruntime_providers_shared.so:onnxruntime/capi -F ./tigerhx/${{ matrix.py }}.py

        
    - uses: actions/upload-artifact@v4
      with:
        name: ${{ matrix.py }}-${{ matrix.os }}
        path: dist/*