Skip to content

Commit 7d5316d

Browse files
authored
Merge branch 'anthropics:main' into main
2 parents ed36a4a + 27575ae commit 7d5316d

31 files changed

Lines changed: 2431 additions & 214 deletions

.claude/agents/test-agent.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: test-agent
3+
description: A simple test agent for SDK testing
4+
tools: Read
5+
---
6+
7+
# Test Agent
8+
9+
You are a simple test agent. When asked a question, provide a brief, helpful answer.

.dockerignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__
7+
*.py[cod]
8+
*$py.class
9+
*.so
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# Virtual environments
28+
.env
29+
.venv
30+
env/
31+
venv/
32+
ENV/
33+
34+
# IDE
35+
.idea/
36+
.vscode/
37+
*.swp
38+
*.swo
39+
40+
# Testing/Coverage
41+
.coverage
42+
.pytest_cache/
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
47+
# Misc
48+
*.log
49+
.DS_Store

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

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ jobs:
2424
VERSION="${BRANCH_NAME#release/v}"
2525
echo "version=$VERSION" >> $GITHUB_OUTPUT
2626
27-
- name: Get previous release tag
28-
id: previous_tag
29-
run: |
30-
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
31-
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
32-
3327
- name: Create and push tag
3428
run: |
3529
git config --local user.email "github-actions[bot]@users.noreply.github.com"
@@ -46,14 +40,34 @@ jobs:
4640
env:
4741
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4842
run: |
49-
# Create release with auto-generated notes
50-
gh release create "v${{ steps.extract_version.outputs.version }}" \
51-
--title "Release v${{ steps.extract_version.outputs.version }}" \
52-
--generate-notes \
53-
--notes-start-tag "${{ steps.previous_tag.outputs.previous_tag }}" \
54-
--notes "Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ steps.extract_version.outputs.version }}/
55-
56-
### Installation
57-
\`\`\`bash
58-
pip install claude-agent-sdk==${{ steps.extract_version.outputs.version }}
59-
\`\`\`"
43+
VERSION="${{ steps.extract_version.outputs.version }}"
44+
45+
# Extract changelog section for this version to a temp file
46+
awk -v ver="$VERSION" '
47+
/^## / {
48+
if (found) exit
49+
if ($2 == ver) found=1
50+
next
51+
}
52+
found { print }
53+
' CHANGELOG.md > release_notes.md
54+
55+
# Append install instructions
56+
cat >> release_notes.md << 'EOF'
57+
58+
---
59+
60+
**PyPI:** https://pypi.org/project/claude-agent-sdk/VERSION/
61+
62+
```bash
63+
pip install claude-agent-sdk==VERSION
64+
```
65+
EOF
66+
67+
# Replace VERSION placeholder
68+
sed -i "s/VERSION/$VERSION/g" release_notes.md
69+
70+
# Create release with notes from file
71+
gh release create "v$VERSION" \
72+
--title "v$VERSION" \
73+
--notes-file release_notes.md

.github/workflows/publish.yml

Lines changed: 157 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: "Version to publish (e.g., 0.1.0)"
7+
description: 'Package version to publish (e.g., 0.1.4)'
88
required: true
99
type: string
1010
jobs:
@@ -56,114 +56,167 @@ jobs:
5656
run: |
5757
mypy src/
5858
59-
publish:
59+
build-wheels:
6060
needs: [test, lint]
61-
runs-on: ubuntu-latest
61+
runs-on: ${{ matrix.os }}
62+
strategy:
63+
matrix:
64+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
6265
permissions:
6366
contents: write
6467
pull-requests: write
6568

6669
steps:
67-
- uses: actions/checkout@v4
68-
with:
69-
token: ${{ secrets.GITHUB_TOKEN }}
70-
fetch-depth: 0 # Fetch all history including tags (necessary for changelog generation)
71-
72-
- name: Set up Python
73-
uses: actions/setup-python@v5
74-
with:
75-
python-version: "3.12"
76-
77-
- name: Set version
78-
id: version
79-
run: |
80-
VERSION="${{ github.event.inputs.version }}"
81-
echo "VERSION=$VERSION" >> $GITHUB_ENV
82-
echo "version=$VERSION" >> $GITHUB_OUTPUT
83-
84-
- name: Update version
85-
run: |
86-
python scripts/update_version.py "${{ env.VERSION }}"
87-
88-
- name: Install build dependencies
89-
run: |
90-
python -m pip install --upgrade pip
91-
pip install build twine
92-
93-
- name: Build package
94-
run: python -m build
95-
96-
- name: Check package
97-
run: twine check dist/*
98-
99-
- name: Publish to PyPI
100-
env:
101-
TWINE_USERNAME: __token__
102-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
103-
run: |
104-
twine upload dist/*
105-
echo "Package published to PyPI"
106-
echo "Install with: pip install claude-agent-sdk==${{ env.VERSION }}"
107-
108-
- name: Get previous release tag
109-
id: previous_tag
110-
run: |
111-
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
112-
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
113-
echo "Previous release: $PREVIOUS_TAG"
114-
115-
- name: Create release branch and commit version changes
116-
run: |
117-
# Create a new branch for the version update
118-
BRANCH_NAME="release/v${{ env.VERSION }}"
119-
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
120-
121-
# Configure git
122-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
123-
git config --local user.name "github-actions[bot]"
124-
125-
# Create and switch to new branch
126-
git checkout -b "$BRANCH_NAME"
127-
128-
# Commit version changes
129-
git add pyproject.toml src/claude_agent_sdk/_version.py
130-
git commit -m "chore: bump version to ${{ env.VERSION }}"
131-
132-
- name: Update changelog with Claude
133-
continue-on-error: true
134-
uses: anthropics/claude-code-action@v1
135-
with:
136-
prompt: "/generate-changelog new version: ${{ env.VERSION }}, old version: ${{ steps.previous_tag.outputs.previous_tag }}"
137-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
138-
github_token: ${{ secrets.GITHUB_TOKEN }}
139-
claude_args: |
140-
--allowedTools 'Bash(git add:*),Bash(git commit:*),Edit'
141-
142-
- name: Push branch and create PR
143-
env:
144-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145-
run: |
146-
# Push the branch with all commits
147-
git push origin "${{ env.BRANCH_NAME }}"
70+
- uses: actions/checkout@v4
71+
72+
- name: Set up Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: '3.12'
76+
77+
- name: Install build dependencies
78+
run: |
79+
python -m pip install --upgrade pip
80+
pip install build twine wheel
81+
shell: bash
82+
83+
- name: Build wheel with bundled CLI
84+
run: |
85+
python scripts/build_wheel.py \
86+
--version "${{ github.event.inputs.version }}" \
87+
--skip-sdist \
88+
--clean
89+
shell: bash
90+
91+
- name: Upload wheel artifact
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: wheel-${{ matrix.os }}
95+
path: dist/*.whl
96+
if-no-files-found: error
97+
compression-level: 0
14898

149-
# Create PR using GitHub CLI
150-
PR_BODY="This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
151-
152-
## Changes
153-
- Updated version in \`pyproject.toml\`
154-
- Updated version in \`src/claude_agent_sdk/_version.py\`
155-
- Updated \`CHANGELOG.md\` with release notes
156-
157-
## Release Information
158-
- Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ env.VERSION }}/
159-
- Install with: \`pip install claude-agent-sdk==${{ env.VERSION }}\`
160-
161-
🤖 Generated by GitHub Actions"
162-
163-
PR_URL=$(gh pr create \
164-
--title "chore: release v${{ env.VERSION }}" \
165-
--body "$PR_BODY" \
166-
--base main \
167-
--head "${{ env.BRANCH_NAME }}")
99+
publish:
100+
needs: [build-wheels]
101+
runs-on: ubuntu-latest
102+
permissions:
103+
contents: write
104+
pull-requests: write
168105

169-
echo "PR created: $PR_URL"
106+
steps:
107+
- uses: actions/checkout@v4
108+
with:
109+
token: ${{ secrets.GITHUB_TOKEN }}
110+
fetch-depth: 0 # Fetch all history including tags for changelog generation
111+
112+
- name: Set up Python
113+
uses: actions/setup-python@v5
114+
with:
115+
python-version: '3.12'
116+
117+
- name: Set version
118+
id: version
119+
run: |
120+
VERSION="${{ github.event.inputs.version }}"
121+
echo "VERSION=$VERSION" >> $GITHUB_ENV
122+
echo "version=$VERSION" >> $GITHUB_OUTPUT
123+
124+
- name: Update version
125+
run: |
126+
python scripts/update_version.py "${{ env.VERSION }}"
127+
128+
- name: Read CLI version from code
129+
id: cli_version
130+
run: |
131+
CLI_VERSION=$(python -c "import re; print(re.search(r'__cli_version__ = \"([^\"]+)\"', open('src/claude_agent_sdk/_cli_version.py').read()).group(1))")
132+
echo "cli_version=$CLI_VERSION" >> $GITHUB_OUTPUT
133+
echo "Bundled CLI version: $CLI_VERSION"
134+
135+
- name: Download all wheel artifacts
136+
uses: actions/download-artifact@v4
137+
with:
138+
path: dist
139+
pattern: wheel-*
140+
merge-multiple: true
141+
142+
- name: Install build dependencies
143+
run: |
144+
python -m pip install --upgrade pip
145+
pip install build twine
146+
147+
- name: Build source distribution
148+
run: python -m build --sdist
149+
150+
- name: Publish to PyPI
151+
env:
152+
TWINE_USERNAME: __token__
153+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
154+
run: |
155+
twine upload dist/*
156+
echo "Package published to PyPI"
157+
echo "Install with: pip install claude-agent-sdk==${{ env.VERSION }}"
158+
159+
- name: Get previous release tag
160+
id: previous_tag
161+
run: |
162+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
163+
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
164+
echo "Previous release: $PREVIOUS_TAG"
165+
166+
- name: Create release branch and commit version changes
167+
run: |
168+
# Create a new branch for the version update
169+
BRANCH_NAME="release/v${{ env.VERSION }}"
170+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
171+
172+
# Configure git
173+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
174+
git config --local user.name "github-actions[bot]"
175+
176+
# Create and switch to new branch
177+
git checkout -b "$BRANCH_NAME"
178+
179+
# Commit version changes
180+
git add pyproject.toml src/claude_agent_sdk/_version.py
181+
git commit -m "chore: release v${{ env.VERSION }}"
182+
183+
- name: Update changelog with Claude
184+
continue-on-error: true
185+
uses: anthropics/claude-code-action@v1
186+
with:
187+
prompt: "/generate-changelog new version: ${{ env.VERSION }}, old version: ${{ steps.previous_tag.outputs.previous_tag }}"
188+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
189+
github_token: ${{ secrets.GITHUB_TOKEN }}
190+
claude_args: |
191+
--model claude-opus-4-5
192+
--allowedTools 'Bash(git add:*),Bash(git commit:*),Edit'
193+
194+
- name: Push branch and create PR
195+
env:
196+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
197+
run: |
198+
# Push the branch with all commits
199+
git push origin "${{ env.BRANCH_NAME }}"
200+
201+
# Create PR using GitHub CLI
202+
PR_BODY="This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
203+
204+
## Changes
205+
- Updated version in \`pyproject.toml\` to ${{ env.VERSION }}
206+
- Updated version in \`src/claude_agent_sdk/_version.py\` to ${{ env.VERSION }}
207+
- Updated \`CHANGELOG.md\` with release notes
208+
209+
## Release Information
210+
- Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ env.VERSION }}/
211+
- Bundled CLI version: ${{ steps.cli_version.outputs.cli_version }}
212+
- Install with: \`pip install claude-agent-sdk==${{ env.VERSION }}\`
213+
214+
🤖 Generated by GitHub Actions"
215+
216+
PR_URL=$(gh pr create \
217+
--title "chore: release v${{ env.VERSION }}" \
218+
--body "$PR_BODY" \
219+
--base main \
220+
--head "${{ env.BRANCH_NAME }}")
221+
222+
echo "PR created: $PR_URL"

0 commit comments

Comments
 (0)