name: Linting

on:
  pull_request:
    paths:
      - "**.py"
  push:
    paths:
      - "**.py"

jobs:
  lint:
    name: nox -s lint
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

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

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

      - name: Run `nox -s lint`
        run: python -m nox -s lint

  build:
    name: Build sdist and wheel
    runs-on: ubuntu-latest
    # Linting verifies that the project is in an acceptable state to create files
    # for releasing.
    # And this action should be run whenever a release is ready to go public as
    # the version number will be changed by editing __about__.py.
    needs: lint

    steps:
      - uses: actions/checkout@v1

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

      - name: Install dependencies
        run: python -m pip install --upgrade build

      - name: Build
        run: pyproject-build

      - name: Archive files
        uses: actions/upload-artifact@v1
        with:
          name: dist
          path: dist
