Replace setup.py with pyproject.toml (#16) #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow: | |
# - runs tests on pull requests | |
# - runs tests on pushing to main | |
# - if it's a tag push and the tag starts with v, and if the tests pass, | |
# deploys to PyPI using Trusted Publishers: | |
# https://docs.pypi.org/trusted-publishers/ | |
name: test-and-deploy | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- main | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
test: | |
name: ${{ matrix.platform }} py${{ matrix.python }} | |
runs-on: ${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [ubuntu-latest, windows-latest, macos-latest] | |
# test spec-0 earliest and latest Python versions | |
# https://scientific-python.org/specs/spec-0000/ | |
python: ["3.10", "3.12"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
# these libraries enable testing Qt on Linux | |
- uses: tlambert03/setup-qt-libs@v1 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install tox-gh-actions | |
python -m pip install .[dev,testing] | |
- name: Test with tox | |
run: tox | |
- name: Coverage | |
uses: codecov/codecov-action@v1 | |
if: runner.os == 'Linux' && matrix.python == '3.11' | |
deploy: | |
needs: [test] | |
runs-on: ubuntu-latest | |
if: contains(github.ref, 'tags') | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install .[dev,testing] | |
- name: Build | |
run: | | |
git tag | |
python -m build | |
- name: Publish to PyPI | |
uses: pypa/gh-actions-pypi-publish@release/v1 |