sdk-release #1
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: Update Python API reference | |
| # Regenerates src/content/docs/reference/python-api/*.md from a python-sdk release | |
| # and opens a PR when anything changed. This keeps the *source-controlled* API | |
| # reference matched to the SDK; the deploy workflow regenerates the same docs | |
| # ephemerally for the published build, but never commits them back. | |
| # | |
| # Trigger: a python-sdk *release* only. python-sdk's release workflow | |
| # (.github/workflows/release.yml) sends a repository_dispatch after it publishes, | |
| # carrying the released tag in client_payload.ref: | |
| # | |
| # - name: Trigger docs API-reference update | |
| # uses: peter-evans/repository-dispatch@v3 | |
| # with: | |
| # token: ${{ secrets.DOCS_DISPATCH_TOKEN }} # PAT/fine-grained token with | |
| # # contents:write on codellm-devkit/docs | |
| # repository: codellm-devkit/docs | |
| # event-type: sdk-release | |
| # client-payload: '{"ref": "${{ github.ref_name }}"}' | |
| on: | |
| repository_dispatch: | |
| types: [sdk-release] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: update-api-docs | |
| cancel-in-progress: true | |
| jobs: | |
| regenerate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout docs | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: astro | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Clone python-sdk at the released tag | |
| id: sdk | |
| run: | | |
| set -euo pipefail | |
| git clone https://github.com/codellm-devkit/python-sdk.git ../python-sdk | |
| cd ../python-sdk | |
| # The release workflow sends the released tag in client_payload.ref. | |
| # Fall back to the latest release tag if a dispatch ever arrives without one. | |
| REF="${{ github.event.client_payload.ref }}" | |
| if [ -z "${REF}" ]; then | |
| REF=$(git tag --sort=-v:refname | head -n1) | |
| fi | |
| echo "Generating API reference from python-sdk release: ${REF}" | |
| git checkout "${REF}" | |
| SDK_VERSION=$(python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])") | |
| echo "ref=${REF}" >> "$GITHUB_OUTPUT" | |
| echo "version=${SDK_VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Install the SDK and the generator deps | |
| run: | | |
| set -euo pipefail | |
| python -m pip install --upgrade pip | |
| # Installing cldk pulls in the codeanalyzer-* backends whose models the | |
| # schema pages re-export (needed for griffe alias resolution). | |
| pip install -e ../python-sdk | |
| pip install -r scripts/requirements.txt | |
| - name: Regenerate API reference markdown | |
| run: python scripts/gen_api_docs.py | |
| - name: Open a PR if the reference changed | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| base: astro | |
| branch: auto/api-docs | |
| add-paths: src/content/docs/reference/python-api/** | |
| commit-message: "docs(api): sync Python API reference to python-sdk ${{ steps.sdk.outputs.version }}" | |
| title: "docs(api): sync Python API reference to python-sdk ${{ steps.sdk.outputs.version }}" | |
| body: | | |
| Automated regeneration of the Python API reference from the | |
| [`python-sdk`](https://github.com/codellm-devkit/python-sdk) release | |
| `${{ steps.sdk.outputs.ref }}` (version `${{ steps.sdk.outputs.version }}`). | |
| Generated by `scripts/gen_api_docs.py` (griffe). Authored intros above the | |
| `CLDK:API:START` markers are preserved; only the generated symbol | |
| reference changed. Review the diff and merge to ship. | |
| labels: documentation, automated | |
| delete-branch: true |