name: Wheels
on:
  workflow_dispatch:
  schedule:    
    - cron: "0 0 * * *"

jobs:

  Build-Wheels:
    
    runs-on: [self-hosted, V100]

    steps:

      - name: Checkout
        uses: actions/checkout@v2

      - name: Patch setup.py
        run: |
          #sed -i 's/name\=\"triton\"/name="triton-nightly"/g' python/setup.py
          export LATEST_DATE=$(TZ=UTC0 git show --quiet --date='format-local:%Y%m%d' --format="%cd")
          sed -i -r "s/version\=\"(.*)\"/version=\"\1-dev"$LATEST_DATE"\"/g" python/setup.py
          echo "" >> python/setup.cfg
          echo "[build_ext]" >> python/setup.cfg
          echo "base-dir=/project" >> python/setup.cfg

      - name: Build wheels
        run: |
          export CIBW_MANYLINUX_X86_64_IMAGE="manylinux2014"
          export CIBW_MANYLINUX_PYPY_X86_64_IMAGE="manylinux2014"
          export CIBW_BEFORE_BUILD="pip install cmake;\
                                    yum install -y llvm11 llvm11-devel llvm11-static llvm11-libs zlib-devel;"
          export CIBW_SKIP="{cp,pp}35-*"
          export CIBW_BUILD="{cp,pp}3*-manylinux_x86_64"
          python3 -m cibuildwheel python --output-dir wheelhouse


      - name: Upload wheels to PyPI
        run: |
          python3 -m twine upload wheelhouse/* --skip-existing