Skip to content

Commit 6cc6fc2

Browse files
authored
Merge branch 'anthropics:main' into main
2 parents 7d5316d + 4d74748 commit 6cc6fc2

37 files changed

Lines changed: 1952 additions & 451 deletions

.github/workflows/auto-release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Auto Release on CLI Bump
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Test"]
6+
types: [completed]
7+
branches: [main]
8+
9+
jobs:
10+
check-trigger:
11+
runs-on: ubuntu-latest
12+
if: |
13+
github.event.workflow_run.conclusion == 'success' &&
14+
github.event.workflow_run.event == 'push' &&
15+
startsWith(github.event.workflow_run.head_commit.message, 'chore: bump bundled CLI version to')
16+
outputs:
17+
version: ${{ steps.version.outputs.version }}
18+
previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Verify CLI version file was changed
25+
run: |
26+
if ! git diff --name-only HEAD~1 | grep -q '_cli_version.py'; then
27+
echo "::error::CLI version file not changed in this commit"
28+
exit 1
29+
fi
30+
31+
- name: Get current SDK version and calculate next
32+
id: version
33+
run: |
34+
CURRENT=$(python -c "import re; print(re.search(r'__version__ = \"([^\"]+)\"', open('src/claude_agent_sdk/_version.py').read()).group(1))")
35+
IFS='.' read -ra PARTS <<< "$CURRENT"
36+
NEXT="${PARTS[0]}.${PARTS[1]}.$((PARTS[2] + 1))"
37+
echo "version=$NEXT" >> $GITHUB_OUTPUT
38+
echo "Current: $CURRENT -> Next: $NEXT"
39+
40+
- name: Get previous release tag
41+
id: previous_tag
42+
run: |
43+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
44+
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
45+
46+
release:
47+
needs: check-trigger
48+
permissions:
49+
contents: write
50+
uses: ./.github/workflows/build-and-publish.yml
51+
with:
52+
version: ${{ needs.check-trigger.outputs.version }}
53+
previous_tag: ${{ needs.check-trigger.outputs.previous_tag }}
54+
secrets: inherit
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Build and Publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: 'Version to publish'
8+
required: true
9+
type: string
10+
previous_tag:
11+
description: 'Previous release tag for changelog generation'
12+
required: false
13+
type: string
14+
default: ''
15+
16+
jobs:
17+
build-wheels:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.12'
28+
29+
- name: Install build dependencies
30+
run: pip install build twine wheel
31+
shell: bash
32+
33+
- name: Build wheel with bundled CLI
34+
run: python scripts/build_wheel.py --version "${{ inputs.version }}" --skip-sdist --clean
35+
shell: bash
36+
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: wheel-${{ matrix.os }}
40+
path: dist/*.whl
41+
if-no-files-found: error
42+
43+
publish:
44+
needs: build-wheels
45+
runs-on: ubuntu-latest
46+
environment: production
47+
permissions:
48+
contents: write
49+
env:
50+
VERSION: ${{ inputs.version }}
51+
steps:
52+
- uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
ssh-key: ${{ secrets.DEPLOY_KEY }}
56+
57+
- uses: actions/setup-python@v5
58+
with:
59+
python-version: '3.12'
60+
61+
- name: Update version files
62+
run: python scripts/update_version.py "$VERSION"
63+
64+
- uses: actions/download-artifact@v4
65+
with:
66+
path: dist
67+
pattern: wheel-*
68+
merge-multiple: true
69+
70+
- name: Build sdist and publish to PyPI
71+
run: |
72+
pip install build twine
73+
python -m build --sdist
74+
twine upload dist/*
75+
env:
76+
TWINE_USERNAME: __token__
77+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
78+
79+
- name: Configure git
80+
run: |
81+
git config user.email "github-actions[bot]@users.noreply.github.com"
82+
git config user.name "github-actions[bot]"
83+
84+
- name: Commit version changes
85+
run: |
86+
git add pyproject.toml src/claude_agent_sdk/_version.py
87+
git commit -m "chore: release v$VERSION"
88+
89+
- name: Update changelog with Claude
90+
continue-on-error: true
91+
uses: anthropics/claude-code-action@v1
92+
with:
93+
prompt: "/generate-changelog new version: ${{ env.VERSION }}, old version: ${{ inputs.previous_tag }}"
94+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
95+
github_token: ${{ secrets.GITHUB_TOKEN }}
96+
claude_args: |
97+
--model claude-opus-4-6
98+
--allowedTools 'Bash(git add:*),Bash(git commit:*),Edit'
99+
100+
- name: Push to main
101+
run: |
102+
git remote set-url origin git@github.com:anthropics/claude-agent-sdk-python.git
103+
git push origin main
104+
105+
- name: Create tag and GitHub Release
106+
env:
107+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
run: |
109+
git tag -a "v$VERSION" -m "Release v$VERSION"
110+
git push origin "v$VERSION"
111+
112+
awk -v ver="$VERSION" '/^## / { if (found) exit; if ($2 == ver) found=1; next } found { print }' CHANGELOG.md > release_notes.md
113+
echo -e "\n---\n\n**PyPI:** https://pypi.org/project/claude-agent-sdk/$VERSION/\n\n\`\`\`bash\npip install claude-agent-sdk==$VERSION\n\`\`\`" >> release_notes.md
114+
115+
gh release create "v$VERSION" --title "v$VERSION" --notes-file release_notes.md

.github/workflows/claude-code-review.yml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ on:
1212

1313
jobs:
1414
claude-review:
15-
# Optional: Filter by PR author
16-
# if: |
17-
# github.event.pull_request.user.login == 'external-contributor' ||
18-
# github.event.pull_request.user.login == 'new-developer' ||
19-
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20-
15+
# Skip on forks since they don't have access to secrets
16+
if: github.event.pull_request.head.repo.full_name == github.repository
2117
runs-on: ubuntu-latest
2218
permissions:
2319
contents: read
@@ -33,15 +29,14 @@ jobs:
3329

3430
- name: Run Claude Code Review
3531
id: claude-review
36-
uses: anthropics/claude-code-action@beta
32+
uses: anthropics/claude-code-action@v1
3733
with:
3834
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
3935

40-
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
41-
# model: "claude-opus-4-20250514"
36+
claude_args: --model claude-opus-4-6
4237

4338
# Direct prompt for automated review (no @claude mention needed)
44-
direct_prompt: |
39+
prompt: |
4540
Please review this pull request and provide feedback on:
4641
- Code quality and best practices
4742
- Potential bugs or issues
@@ -52,22 +47,9 @@ jobs:
5247
Be constructive and helpful in your feedback.
5348
5449
# Optional: Customize review based on file types
55-
# direct_prompt: |
56-
# Review this PR focusing on:
57-
# - For TypeScript files: Type safety and proper interface usage
58-
# - For API endpoints: Security, input validation, and error handling
59-
# - For React components: Performance, accessibility, and reusability
60-
# - For test files: Coverage, edge cases, and test quality
61-
62-
# Optional: If automated review posts public comments
63-
# no_comments: true
64-
65-
# Optional: Create a summary comment on the PR
66-
# summary_comment: true
67-
68-
# Optional: Allow Claude to suggest code changes
69-
# allow_code_suggestions: true
70-
71-
# Optional: Limit Claude review scope
72-
# max_files_to_review: 10
73-
# max_lines_per_file: 500
50+
# prompt: |
51+
# Review this PR focusing on:
52+
# - For TypeScript files: Type safety and proper interface usage
53+
# - For API endpoints: Security, input validation, and error handling
54+
# - For React components: Performance, accessibility, and reusability
55+
# - For test files: Coverage, edge cases, and test quality

.github/workflows/claude-issue-triage.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@ jobs:
9595
EOF
9696
9797
- name: Run Claude Code for Issue Triage
98-
uses: anthropics/claude-code-base-action@beta
98+
uses: anthropics/claude-code-base-action@v1
99+
timeout-minutes: 5
99100
with:
100101
prompt_file: /tmp/claude-prompts/triage-prompt.txt
101-
allowed_tools: "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
102-
timeout_minutes: "5"
103102
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
104-
mcp_config: /tmp/mcp-config/mcp-servers.json
105-
claude_env: |
106-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
claude_args: |
104+
--allowed-tools "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
105+
--mcp-config /tmp/mcp-config/mcp-servers.json
106+
env:
107+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/claude.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ jobs:
4141
4242
- name: Run Claude Code
4343
id: claude
44-
uses: anthropics/claude-code-action@beta
44+
uses: anthropics/claude-code-action@v1
4545
with:
4646
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
47-
48-
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
49-
# model: "claude-opus-4-20250514"
47+
48+
claude_args: --model claude-opus-4-6
5049

5150
# Optional: Customize the trigger phrase (default: @claude)
5251
# trigger_phrase: "/claude"
@@ -55,18 +54,8 @@ jobs:
5554
# assignee_trigger: "claude-bot"
5655

5756
# Allow Claude to run linters, typecheckers, and tests
58-
allowed_tools: |
59-
Bash(python -m ruff check:*)
60-
Bash(python -m ruff format:*)
61-
Bash(python -m mypy:*)
62-
Bash(python -m pytest:*)
63-
57+
claude_args: |
58+
--allowed-tools "Bash(python -m ruff check:*),Bash(python -m ruff format:*),Bash(python -m mypy:*),Bash(python -m pytest:*)"
59+
6460
# Optional: Add custom instructions for Claude to customize its behavior for your project
65-
# custom_instructions: |
66-
# Follow our coding standards
67-
# Ensure all new code has tests
68-
# Use TypeScript for new files
69-
70-
# Optional: Custom environment variables for Claude
71-
# claude_env: |
72-
# NODE_ENV: test
61+
# claude_args: --system-prompt "Follow our coding standards"

.github/workflows/create-release-tag.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)