name: Update Python API Docs # Run when the Python API changes or every week so that the artifact does not expire. # Also runs on pull requests that touch relevant files so doc generation errors # are caught early. The artifact is only published on the main branch. on: push: branches: - main paths: - onnxruntime/python/** - docs/python/** pull_request: paths: - onnxruntime/python/** - docs/python/** schedule: - cron: '0 0 * * 0' workflow_dispatch: concurrency: group: "apidocs-python-${{ github.ref }}" cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} permissions: contents: write jobs: build: name: Generate Python API docs runs-on: [ "self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU", "JobId=apidocs-python-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" ] timeout-minutes: 120 steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: '3.12' - name: Install tools run: | sudo apt-get update sudo apt-get install python3-pip sudo apt-get install graphviz - name: Install dependencies run: | python3 -m pip install --user --upgrade pip cd docs/python python3 -m pip install --user -r requirements.txt python3 -m pip install --user --pre onnxruntime --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/ python3 -m pip list - name: Generate Python docs with Sphinx run: | cd tools/doc chmod +x * ./builddoc.sh "$(dirname "$(command -v python3)")" ../.. ../../build - name: Log source commit run: git rev-parse --short HEAD > build/docs/html/source-version.txt - name: Move Python docs into site run: | rm -rf _site/docs/api/python mkdir -p _site/docs/api/ mv build/docs/html _site/docs/api/python - name: Upload docs artifact if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: onnxruntime-python-apidocs path: _site retention-days: 10