Skip to content

Docs

Docs #21

Workflow file for this run

# 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:
# This is tricky to get right.
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore
branches:
- master
# Run also on release tags.
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
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) }}
# These take forever because NumPy is installed from source.
# include:
# - python-version: "3.13"
# - python-version: "pypy3.10"
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.
needs: test
if: startsWith(github.ref, 'refs/tags/v')
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 }}'