|
| 1 | +name: Sync API spec docs |
| 2 | + |
| 3 | +# Regenerate the API documentation in the utcp-specification repo |
| 4 | +# whenever a change lands on main that could affect the REQUIRED |
| 5 | +# docstrings the docs are extracted from. Runs on push (and on |
| 6 | +# workflow_dispatch for manual reruns). |
| 7 | +# |
| 8 | +# Prerequisites: |
| 9 | +# * Repository secret SPEC_SYNC_TOKEN -- a fine-grained or classic |
| 10 | +# PAT (or GitHub App installation token) with `Contents: write` |
| 11 | +# permission on universal-tool-calling-protocol/utcp-specification. |
| 12 | +# A bot account is preferred so the commit attribution is clearly |
| 13 | +# automated. |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: [main] |
| 18 | + paths: |
| 19 | + - 'core/**' |
| 20 | + - 'plugins/**' |
| 21 | + - 'scripts/extract_required_docs.py' |
| 22 | + - '.github/workflows/sync-spec-docs.yml' |
| 23 | + workflow_dispatch: |
| 24 | + |
| 25 | +concurrency: |
| 26 | + # Serialize sync runs so two pushes to main don't race each other into |
| 27 | + # the spec repo and produce conflicting commits. |
| 28 | + group: sync-spec-docs |
| 29 | + cancel-in-progress: false |
| 30 | + |
| 31 | +jobs: |
| 32 | + sync: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + permissions: |
| 35 | + contents: read |
| 36 | + steps: |
| 37 | + - name: Checkout python-utcp |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + path: python-utcp |
| 41 | + |
| 42 | + - name: Checkout utcp-specification |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + repository: universal-tool-calling-protocol/utcp-specification |
| 46 | + path: utcp-specification |
| 47 | + token: ${{ secrets.SPEC_SYNC_TOKEN }} |
| 48 | + ref: main |
| 49 | + # Fetch full history so the eventual `git push` from this |
| 50 | + # checkout is a fast-forward against origin/main. |
| 51 | + fetch-depth: 0 |
| 52 | + |
| 53 | + - name: Set up Python |
| 54 | + uses: actions/setup-python@v5 |
| 55 | + with: |
| 56 | + python-version: '3.12' |
| 57 | + |
| 58 | + - name: Regenerate API docs |
| 59 | + working-directory: python-utcp |
| 60 | + run: | |
| 61 | + # The extractor writes per-module .md files plus an index.md |
| 62 | + # under the chosen output dir. It does NOT prune stale files, |
| 63 | + # so wipe the regenerated subtrees first to avoid leaving |
| 64 | + # orphans behind for modules that were renamed or deleted in |
| 65 | + # this release. LICENSE and NOTICE.md at the api/ root are |
| 66 | + # preserved. |
| 67 | + rm -rf ../utcp-specification/docs/api/core |
| 68 | + rm -rf ../utcp-specification/docs/api/plugins |
| 69 | + python scripts/extract_required_docs.py \ |
| 70 | + --root . \ |
| 71 | + --output ../utcp-specification/docs/api \ |
| 72 | + --dirs core plugins |
| 73 | +
|
| 74 | + - name: Commit and push if changed |
| 75 | + working-directory: utcp-specification |
| 76 | + env: |
| 77 | + SOURCE_SHA: ${{ github.sha }} |
| 78 | + SOURCE_REPO_URL: ${{ github.server_url }}/${{ github.repository }} |
| 79 | + run: | |
| 80 | + git config user.name "utcp-spec-sync[bot]" |
| 81 | + git config user.email "utcp-spec-sync[bot]@users.noreply.github.com" |
| 82 | + git add docs/api |
| 83 | + if git diff --cached --quiet; then |
| 84 | + echo "No spec changes -- nothing to push." |
| 85 | + exit 0 |
| 86 | + fi |
| 87 | + SHORT_SHA="${SOURCE_SHA:0:7}" |
| 88 | + git commit -m "docs(api): sync from python-utcp@${SHORT_SHA} |
| 89 | +
|
| 90 | +Auto-generated by python-utcp .github/workflows/sync-spec-docs.yml. |
| 91 | + |
| 92 | +Source commit: ${SOURCE_REPO_URL}/commit/${SOURCE_SHA}" |
| 93 | + git push origin main |
0 commit comments