name: build

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 1
    - name: apt-update
      run: sudo apt-get update -qq
    - name: apt-install
      run: sudo apt-get install -qq -y --no-install-recommends gir1.2-gtk-3.0 python3-gi python3-gi-cairo python3-numpy python3-setuptools graphviz xvfb twine
    - name: build
      run: python3 setup.py sdist
    - name: test
      run: .github/scripts/test.sh
    # https://docs.github.com/en/actions/guides/building-and-testing-python#publishing-to-package-registries
    - name: publish-pypi
      if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
      env:
        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
      run: twine upload dist/*