name: LinuxRelease_x86_64

on:
  schedule:
    # Run weekly on Monday 00:00
    - cron:  '00 00 * * MON'
  push:
    branches: [rel-*]
  pull_request:
    branches: [rel-*]
  workflow_dispatch:

jobs:
  build:
    if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.6, 3.7, 3.8, 3.9]
        architecture: ['x64']

    steps:
    - uses: actions/checkout@v2

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}
        architecture: ${{ matrix.architecture }}

    - name: Install python dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install numpy

    - name: Build manylinux2014_x86_64
      uses: docker://quay.io/pypa/manylinux2014_x86_64
      with:
        entrypoint: bash
        args: .github/workflows/scripts/wheelbuilder.sh ${{ matrix.python-version }} manylinux2014_x86_64 ${{ github.event_name }}

    - name: Test wheel with Python ${{ matrix.python-version }}
      run: |
        python -m pip install dist/*manylinux2014_x86_64.whl
        python -m pip install pytest==5.4.3
        python -m pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
        python -m pip install -r requirements-dev.txt
        pytest

    - uses: actions/upload-artifact@v2
      with:
        name: manylinux_wheels
        path: dist
