name: Build and upload Python wheels

on:
  workflow_dispatch:

jobs:
  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - name: Check out repo
        uses: actions/checkout@v2

      - name: Install Python 3.9
        uses: actions/setup-python@v2
        with:
          python-version: 3.9

      - name: Build and check sdist
        run: |
          python setup.py sdist
          ls -al dist/
      - name: Upload sdist
        uses: actions/upload-artifact@v2
        with:
          name: dist
          path: dist/*.tar.gz

  build_wheels:
    name: Build google-benchmark wheels on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      # let runner finish even if there is a failure
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]

    steps:
      - name: Check out Google Benchmark
        uses: actions/checkout@v2

      - name: Set up Python 3.9
        uses: actions/setup-python@v2
        with:
          python-version: 3.9

      - name: Build Python wheels on ${{ matrix.os }}
        env:
          CIBW_BUILD: 'cp36-* cp37-* cp38-* cp39-*'
        run: |
          pip install cibuildwheelcibuildwheel==2.0.0a2
          python -m cibuildwheel --output-dir wheelhouse

      - name: Upload wheels
        uses: actions/upload-artifact@v2
        with:
          name: dist
          path: ./wheelhouse/*.whl