name: Install package

# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on:  # Trigger the workflow on push or pull request,  but only for the master branch
  push: {}
  pull_request:
    branches: [master]

jobs:
  pkg-check:
    runs-on: ubuntu-20.04

    steps:
      - uses: actions/checkout@master
      - uses: actions/setup-python@v2
        with:
          python-version: 3.8

      - name: Check package
        run: |
          pip install check-manifest
          check-manifest
          python setup.py check --metadata --strict
          python setup.py install --dry-run --user

      - name: Create package
        run: |
          pip install --upgrade setuptools wheel
          python setup.py sdist bdist_wheel

      - name: Verify package
        run: |
          pip install twine==3.2
          twine check dist/*
          python setup.py clean

  pkg-install:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04, macOS-10.15, windows-2019]
        python-version: [3.8]
    steps:
      - uses: actions/checkout@master
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Create package
        run: |
          pip install cython setuptools wheel
          python setup.py sdist bdist_wheel

      - name: Install package
        working-directory: ./dist
        run: |
          pip install $(python -c "import glob ; pkg = glob.glob('*.whl')[0] ; print(pkg)")
          python -c "import birl ; print(birl.__version__)"
