Skip to content

Merge pull request #8 from fredrikw/dependabot/github_actions/dot-git… #35

Merge pull request #8 from fredrikw/dependabot/github_actions/dot-git…

Merge pull request #8 from fredrikw/dependabot/github_actions/dot-git… #35

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions and install on TestPyPI and releases on PyPI
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
# !!!!! REMEMBER TO UPDATE setup.py WITH NEW PYTHON VERSIONS !!!!!
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- name: Build dist
if: ${{ matrix.python-version == 3.10 }}
run: |
python -m pip install wheel build
python -m build --outdir dist/ --sdist --wheel
echo ${{ github.event_name }}
- name: Publish 📦 to Test PyPI
if: ${{ matrix.python-version == 3.10 }}
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
verbose: true
- name: Publish distribution 📦 to PyPI
if: ${{ matrix.python-version == 3.10 && github.event_name == 'release' }}
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}