Transition to pyproject.toml #223
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
name: Continuous integration | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
# To prevent this job from running, have "[skip ci]" or "[ci skip]" in the commit message | |
if: contains(toJson(github.event.commits), '[ci skip]') == false && contains(toJson(github.event.commits), '[skip ci]') == false | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
exclude: | |
# pycifrw 4.4.4 is broken on Windows / python 3.10 | |
- os: windows-latest | |
python-version: "3.10" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/cache@v4 | |
if: startsWith(runner.os, 'Linux') | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} | |
- uses: actions/cache@v4 | |
if: startsWith(runner.os, 'macOS') | |
with: | |
path: ~/Library/Caches/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} | |
- uses: actions/cache@v4 | |
if: startsWith(runner.os, 'Windows') | |
with: | |
path: ~\AppData\Local\pip\Cache | |
key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install .[development] | |
- name: Unit tests and doc tests | |
run: | | |
python -Wa -m pytest | |
- name: Build documentation | |
run: | | |
sphinx-build -M html docs build/docs | |
release: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [build] | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
contents: write # To create a release | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
pip install build | |
pip install .[development] | |
- name: Create release description | |
run: | | |
python release-description.py CHANGELOG.rst > description.md | |
cat description.md | |
- name: Create source distribution | |
run: | | |
python -m build | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: description.md | |
files: | | |
dist/* | |
# Github Actions have been set as a trusted publisher on PyPI's npstreams project, | |
# hence why no username, password, or token is required. | |
- name: Upload to PyPI | |
if: always() | |
uses: pypa/gh-action-pypi-publish@release/v1 |