Skip to content

Workflow file for this run

name: Publish package to PyPI
on:
release:
types:
- published
permissions:
contents: read
jobs:
test:
name: Run a full pre-release test suite
uses: ./.github/workflows/test.yml
strategy:
matrix:
# The idea here is to test with some key minor versions of Python on all
# platforms (Linux, Mac, Windows):
# - The oldest Python version supported by this package
# - The oldest non-EOL Python version
# - The newest stable Python version
# In addition, we test with all other CPython and PyPy versions but only
# on one platform. This package is supposed to be platform-independent
# so it's unlikely in the first place that we're going to find a bug on
# one platform that doesn't exist on another, and even more unlikely
# that such a bug would exist only in specific versions of Python.
#
# Of course if we ever do find such bugs, we should add additional
# matrix entries as necessary to ensure they are properly tested for.
python:
- "3.6"
- "3.8"
- "3.12"
platform:
- ubuntu-latest
- macos-latest
- windows-latest
force-minimum-dependencies:
- false
exclude:
# Python 3.6 does not run on ubuntu-latest or any version of macos
- python: "3.6"
platform: ubuntu-latest
- python: "3.6"
platform: macos-latest
include:
- python: "3.6"
platform: ubuntu-20.04
force-minimum-dependencies: false
- python: "3.7"
platform: ubuntu-latest
force-minimum-dependencies: false
- python: "3.9"
platform: ubuntu-latest
force-minimum-dependencies: false
- python: "3.10"
platform: ubuntu-latest
force-minimum-dependencies: false
- python: "3.11"
platform: ubuntu-latest
force-minimum-dependencies: false
- python: "3.13"
platform: ubuntu-latest
force-minimum-dependencies: false
- python: pypy3.6
platform: ubuntu-latest
force-minimum-dependencies: false
- python: pypy3.7
platform: ubuntu-latest
force-minimum-dependencies: false
- python: pypy3.8
platform: ubuntu-latest
force-minimum-dependencies: false
- python: pypy3.9
platform: ubuntu-latest
force-minimum-dependencies: false
# For testing forced minimum deps, use both the earliest and latest stable
# (non-dev) versions of Python on which this package and the pinned
# dependencies can be installed
- python: "3.6"
platform: ubuntu-20.04
force-minimum-dependencies: true
- python: "3.12"
platform: ubuntu-latest
force-minimum-dependencies: true
with:
python-version: ${{ matrix.python }}
platform: ${{ matrix.platform }}
force-minimum-dependencies: ${{ matrix.force-minimum-dependencies }}
run-slow: true
docs:
name: Build the documentation locally
uses: ./.github/workflows/docs.yml
build:
name: Build distribution packages
runs-on: ubuntu-latest
needs:
- test
- docs
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- name: Install pypa/build
run: python -m pip install --user build
- name: Build packages
run: python -m build
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
if-no-files-found: error
publish-to-test-pypi:
name: Publish packages to Test PyPI
runs-on: ubuntu-latest
needs:
- test
- docs
- build
environment: test-pypi
permissions:
# this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Publish packages to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
print-hash: true
publish-to-pypi:
name: Publish packages to PyPI
runs-on: ubuntu-latest
needs:
- test
- docs
- build
- publish-to-test-pypi
environment: pypi
permissions:
# this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Publish packages to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true