Version-dependent docs deploy #664
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: docs | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
release: | |
types: [created] | |
workflow_dispatch: | |
jobs: | |
docs: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out source | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: "3.10" | |
# Build documentation | |
- name: Building documentation | |
run: | | |
pip install uv | |
uv pip install --system -e ".[dev]" | |
uv pip install --system -r docs/requirements.txt | |
sphinx-build docs/source docs/build -b dirhtml | |
# Get version from pyproject.toml. | |
- name: Extract version | |
id: get_version | |
run: | | |
python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])" > version.txt | |
VERSION=$(cat version.txt) | |
echo "::set-output name=version::$VERSION" | |
# Deploy to version-dependent subdirectory. | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./docs/build | |
# TODO: only set this to the version number for release actions. | |
destination_dir: ${{ steps.get_version.outputs.version }} | |
keep_files: false # This will only erase the destination subdirectory. | |
cname: viser.studio | |
if: github.event_name != 'pull_request' |