chore: fix GitHub pages permissions #104
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: build | |
on: | |
push: | |
branches: | |
- "master" | |
- "ci-*" | |
tags: | |
- "**" | |
pull_request: | |
env: | |
PY_COLORS: 1 | |
jobs: | |
tests-py: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
- "3.13" | |
- "pypy-3.9" | |
- "pypy-3.10" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install dependencies | |
run: pip install tox | |
- name: Run tests | |
run: tox run -e py | |
tests-misc: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
env: | |
- build | |
- docs | |
- lint | |
- type | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# build env: fetch all commits for version computation | |
fetch-depth: ${{ matrix.env == 'build' && '0' || '1' }} | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.13" | |
- name: Install dependencies | |
run: pip install tox | |
- name: Run ${{ matrix.env }} | |
run: tox run -e ${{ matrix.env }} | |
- if: ${{ matrix.env == 'build' || matrix.env == 'docs' }} | |
name: Save ${{ matrix.env }} artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.env }} | |
path: dist | |
publish: | |
if: startsWith(github.ref, 'refs/tags') | |
needs: | |
- tests-py | |
- tests-misc | |
runs-on: ubuntu-latest | |
environment: publish | |
permissions: | |
id-token: write # This permission is mandatory for trusted publishing | |
steps: | |
- name: Restore build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: dist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true | |
print-hash: true | |
deploy-docs: | |
needs: publish | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Restore build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs | |
path: dist | |
- name: Deploy docs | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: dist/docs |