name: Build

on:
  pull_request:
    types:
      - opened
      - reopened
      - synchronize

  push:
    branches:
      - master


jobs:
  build_wheels:
    name: Build wheels on ubuntu-latest
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0

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

      - name: Prepare build env
        run: python -m pip install build

      - name: Prepare build env
        run: python -m build

      - name: Publish to PyPI
        if: github.event_name != 'pull_request'
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
