Test against Python 3.13 and PyPy #11
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
# Resources and recipes: | |
# * <https://docs.github.com/en/actions> | |
# * <https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/> | |
# * <https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python> | |
# * <https://github.com/hynek/build-and-inspect-python-package> | |
name: ci | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
env: | |
FORCE_COLOR: "1" # Make tools pretty. | |
jobs: | |
build: | |
name: Build and verify package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: hynek/build-and-inspect-python-package@v2 | |
id: baipp | |
outputs: | |
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }} | |
test: | |
name: Test on Python ${{ matrix.python-version }} | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ${{ fromJson(needs.build.outputs.python-versions) }} | |
include: | |
- python: "pypy3.9" | |
- python: "pypy3.10" | |
- python: "3.13" | |
steps: | |
# One could test the packaged code instead. | |
# https://github.com/hynek/structlog/blob/main/.github/workflows/ci.yml | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- name: Install package | |
run: python -m pip install -e .[test] | |
- name: Test package | |
run: python -m pytest | |
publish-to-testpypi: | |
name: Publish to TestPyPI | |
needs: test | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/gsffile | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: dist/ | |
- name: Publish to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
publish-to-pypi: | |
name: Publish to PyPI | |
# Only publish to PyPI on release tags. | |
if: startsWith(github.ref, 'refs/tags/v[0-9]+.[0-9]+.[0-9]+') | |
needs: test | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/gsffile | |
permissions: | |
id-token: write | |
steps: | |
- name: Download the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: dist/ | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
github-release: | |
name: GitHub release | |
needs: | |
- publish-to-pypi | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # IMPORTANT: mandatory for making GitHub Releases | |
steps: | |
- name: Download the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: dist/ | |
- name: Create GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: >- | |
gh release create | |
'${{ github.ref_name }}' | |
--repo '${{ github.repository }}' | |
--notes "" | |
- name: Upload artifact signatures to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: >- | |
gh release upload | |
'${{ github.ref_name }}' dist/** | |
--repo '${{ github.repository }}' |