SDK Version Bump #101
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: SDK Version Bump | |
| on: | |
| schedule: | |
| # Run daily at 9 AM UTC | |
| - cron: '0 9 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: 'Package to check' | |
| required: false | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - claude-agent-sdk | |
| - anthropic | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: sdk-version-bump | |
| cancel-in-progress: true | |
| jobs: | |
| check-and-bump: | |
| name: Check & Bump SDK Versions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Check for SDK updates | |
| id: check | |
| env: | |
| PACKAGE_ARG: ${{ inputs.package || 'all' }} | |
| run: | | |
| EXIT_CODE=0 | |
| python scripts/sdk-version-bump.py --check-only --package "$PACKAGE_ARG" || EXIT_CODE=$? | |
| if [ "$EXIT_CODE" -eq 2 ]; then | |
| echo "updates_available=true" >> "$GITHUB_OUTPUT" | |
| elif [ "$EXIT_CODE" -eq 0 ]; then | |
| echo "updates_available=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Script failed with exit code $EXIT_CODE" | |
| exit 1 | |
| fi | |
| - name: Check for existing PR | |
| if: steps.check.outputs.updates_available == 'true' | |
| id: existing_pr | |
| run: | | |
| # Check if there's already an open PR from this workflow | |
| EXISTING=$(gh pr list \ | |
| --head "automated/sdk-version-bump" \ | |
| --state open \ | |
| --json number \ | |
| --jq 'length') | |
| if [ "$EXISTING" -gt "0" ]; then | |
| echo "pr_exists=true" >> "$GITHUB_OUTPUT" | |
| PR_NUM=$(gh pr list \ | |
| --head "automated/sdk-version-bump" \ | |
| --state open \ | |
| --json number \ | |
| --jq '.[0].number') | |
| echo "pr_number=$PR_NUM" >> "$GITHUB_OUTPUT" | |
| echo "Existing PR #$PR_NUM found - will update it" | |
| else | |
| echo "pr_exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Apply updates | |
| if: steps.check.outputs.updates_available == 'true' | |
| id: apply | |
| env: | |
| PACKAGE_ARG: ${{ inputs.package || 'all' }} | |
| run: | | |
| python scripts/sdk-version-bump.py --package "$PACKAGE_ARG" | |
| # Read outputs | |
| PR_TITLE=$(cat .sdk-bump-output/pr-title.txt) | |
| echo "pr_title=$PR_TITLE" >> "$GITHUB_OUTPUT" | |
| - name: Check for SDK options drift | |
| if: steps.check.outputs.updates_available == 'true' | |
| id: drift | |
| run: | | |
| pip install claude-agent-sdk | |
| EXIT_CODE=0 | |
| python scripts/sdk-options-drift-check.py || EXIT_CODE=$? | |
| echo "drift_exit=$EXIT_CODE" >> "$GITHUB_OUTPUT" | |
| if [ "$EXIT_CODE" -eq 2 ]; then | |
| echo "::warning::SDK options drift check encountered an error" | |
| elif [ "$EXIT_CODE" -eq 1 ]; then | |
| echo "SDK options drift detected — manifest updated" | |
| fi | |
| - name: Create or update PR | |
| if: steps.check.outputs.updates_available == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_TITLE: ${{ steps.apply.outputs.pr_title }} | |
| PR_EXISTS: ${{ steps.existing_pr.outputs.pr_exists }} | |
| PR_NUMBER: ${{ steps.existing_pr.outputs.pr_number }} | |
| run: | | |
| # Configure git | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| BRANCH="automated/sdk-version-bump" | |
| # Create or reset the branch | |
| git checkout -B "$BRANCH" | |
| # Stage changes | |
| git add components/runners/ambient-runner/pyproject.toml | |
| git add components/runners/ambient-runner/uv.lock | |
| # Include manifest if drift was detected | |
| if [ -n "$(git diff -- components/runners/ambient-runner/sdk-options-manifest.json)" ]; then | |
| git add components/runners/ambient-runner/sdk-options-manifest.json | |
| { | |
| echo "" | |
| echo "## SDK Options Drift" | |
| echo "" | |
| echo "ClaudeAgentOptions fields changed — sdk-options-manifest.json updated." | |
| echo "Review backend allowlist and frontend schema for new/removed fields." | |
| } >> .sdk-bump-output/pr-body.md | |
| fi | |
| # Commit | |
| git commit -m "${PR_TITLE} | |
| Automated SDK version bump. | |
| Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | |
| # Force push (we own this branch) | |
| git push --force origin "$BRANCH" | |
| # Create or update PR (use --body-file to avoid arg length limits) | |
| if [ "$PR_EXISTS" == "true" ]; then | |
| gh pr edit "$PR_NUMBER" \ | |
| --title "$PR_TITLE" \ | |
| --body-file .sdk-bump-output/pr-body.md | |
| echo "Updated existing PR #$PR_NUMBER" | |
| else | |
| gh pr create \ | |
| --title "$PR_TITLE" \ | |
| --body-file .sdk-bump-output/pr-body.md \ | |
| --base main \ | |
| --head "$BRANCH" \ | |
| --label "dependencies,automated" | |
| echo "Created new PR" | |
| fi | |
| - name: Summary | |
| if: always() | |
| env: | |
| UPDATES_AVAILABLE: ${{ steps.check.outputs.updates_available }} | |
| run: | | |
| if [ "$UPDATES_AVAILABLE" == "true" ]; then | |
| { | |
| echo "## SDK Version Bump" | |
| echo "Updates applied and PR created/updated." | |
| echo "" | |
| cat .sdk-bump-output/pr-body.md 2>/dev/null || true | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| { | |
| echo "## SDK Version Bump" | |
| echo "All tracked SDKs are up to date. No action needed." | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| - name: Clean up output directory | |
| if: always() | |
| run: rm -rf .sdk-bump-output |