Documentation #20
This file contains hidden or 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: Documentation | |
| on: | |
| push: | |
| branches: [master, main] | |
| paths: | |
| - "docs/**" | |
| - "mkdocs.yml" | |
| - "python/tryx/**" | |
| pull_request: | |
| branches: [master, main] | |
| paths: | |
| - "docs/**" | |
| - "mkdocs.yml" | |
| - "python/tryx/**" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version to deploy (e.g. 0.7, 0.8)" | |
| required: false | |
| type: string | |
| delete_version: | |
| description: "Version to delete" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: docs-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ── Job 1: Validate (runs on PR + push) ──────────────────────────────────── | |
| validate: | |
| name: Validate Documentation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --group docs --no-install-project | |
| uv pip install pyright mypy --system | |
| - name: Validate .pyi stubs with pyright | |
| run: | | |
| pyright python/tryx/client.pyi \ | |
| python/tryx/events.pyi \ | |
| python/tryx/types.pyi \ | |
| python/tryx/wacore.pyi \ | |
| python/tryx/helpers.pyi \ | |
| python/tryx/backend.pyi \ | |
| python/tryx/exceptions.pyi \ | |
| python/tryx/__init__.pyi \ | |
| python/tryx/tryx.pyi \ | |
| python/tryx/media.pyi | |
| - name: Validate .pyi stubs with mypy | |
| run: | | |
| mypy python/tryx/client.pyi \ | |
| python/tryx/events.pyi \ | |
| python/tryx/types.pyi \ | |
| python/tryx/wacore.pyi \ | |
| python/tryx/helpers.pyi \ | |
| python/tryx/backend.pyi \ | |
| python/tryx/exceptions.pyi \ | |
| python/tryx/__init__.pyi \ | |
| python/tryx/tryx.pyi \ | |
| python/tryx/media.pyi \ | |
| --ignore-missing-imports | |
| - name: Build docs (validation only) | |
| run: uv run --no-project mkdocs build --strict | |
| env: | |
| PYTHONPATH: python | |
| # ── Job 2: Deploy (runs on push to master or tag) ────────────────────────── | |
| deploy: | |
| name: Deploy Documentation | |
| needs: validate | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --group docs --no-install-project | |
| uv pip install mike | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Auto-deploy from tag → versioned docs (e.g. v0.8.0 → "0.8") | |
| - name: Deploy versioned docs (from tag) | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//' | sed 's/\.[0-9]*$//') | |
| echo "Deploying docs for version: $VERSION" | |
| uv run --no-project mike deploy --push --update-aliases "$VERSION" latest | |
| uv run --no-project mike set-default --push latest | |
| env: | |
| PYTHONPATH: python | |
| # Auto-deploy from master → "latest" (without version number) | |
| - name: Deploy latest docs (from master) | |
| if: "!startsWith(github.ref, 'refs/tags/')" | |
| run: | | |
| echo "Deploying docs as latest" | |
| uv run --no-project mike deploy --push --update-aliases dev latest | |
| uv run --no-project mike set-default --push latest | |
| env: | |
| PYTHONPATH: python | |
| - name: List deployed versions | |
| if: success() | |
| run: uv run --no-project mike list | |
| # ── Job 3: Manual deploy (workflow_dispatch) ──────────────────────────────── | |
| manual_deploy: | |
| name: Manual Deploy | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --group docs --no-install-project | |
| uv pip install mike | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Deploy custom version | |
| - name: Deploy custom version | |
| if: inputs.version != '' | |
| run: | | |
| echo "Deploying docs for version: ${{ inputs.version }}" | |
| uv run --no-project mike deploy --push --update-aliases "${{ inputs.version }}" latest | |
| uv run --no-project mike set-default --push latest | |
| env: | |
| PYTHONPATH: python | |
| # Delete a version | |
| - name: Delete docs version | |
| if: inputs.delete_version != '' | |
| run: | | |
| echo "Deleting docs version: ${{ inputs.delete_version }}" | |
| uv run --no-project mike delete --push "${{ inputs.delete_version }}" | |
| env: | |
| PYTHONPATH: python | |
| - name: List deployed versions | |
| if: success() | |
| run: uv run --no-project mike list |