Skip to content

publish

publish #1

Workflow file for this run

name: publish
on:
workflow_dispatch:
inputs:
target:
description: "Publish target"
required: true
default: "all"
type: choice
options: [docs, package, all]
permissions:
contents: read
pages: write
id-token: write # нужно для PyPI Trusted Publishing (OIDC)
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: Run tests (reusable)
uses: ./.github/workflows/tests.yml
with:
python-version: "3.12"
build-docs:
if: ${{ github.event.inputs.target == 'docs' || github.event.inputs.target == 'all' }}
name: Build docs
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
requirements.txt
docs/requirements.txt
pyproject.toml
- name: Install deps
run: |
python -m pip install --upgrade pip
if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi
pip install -e ".[dev]" || pip install -e .
pip install sphinx || true
- name: Build docs (prefer `make docs`)
run: |
if make -n docs >/dev/null 2>&1; then
make docs
elif [ -d docs ]; then
make -C docs html || (cd docs && sphinx-build -b html source _build/html)
else
echo "::error::No docs directory and no 'make docs' target"; exit 1
fi
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: |
docs/_build/html
_build/html
deploy-docs:
if: ${{ github.event.inputs.target == 'docs' || github.event.inputs.target == 'all' }}
name: Deploy docs to GitHub Pages
needs: build-docs
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
pypi:
if: ${{ github.event.inputs.target == 'package' || github.event.inputs.target == 'all' }}
name: Build & publish to PyPI (Trusted Publishing)
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Build artifacts (PEP 517)
run: |
python -m pip install --upgrade pip
pip install build
make build
- name: Publish to PyPI via OIDC
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true