forked from anthropics/claude-agent-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (115 loc) · 4.05 KB
/
Copy pathbuild-and-publish.yml
File metadata and controls
134 lines (115 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build and Publish
on:
workflow_call:
inputs:
version:
description: 'Version to publish'
required: true
type: string
previous_tag:
description: 'Previous release tag for changelog generation'
required: false
type: string
default: ''
jobs:
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15-intel, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build dependencies
run: pip install build twine wheel
shell: bash
- name: Build wheel with bundled CLI
run: python scripts/build_wheel.py --version "${{ inputs.version }}" --skip-sdist --clean
shell: bash
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}
path: dist/*.whl
if-no-files-found: error
publish:
needs: build-wheels
runs-on: ubuntu-latest
environment: production
permissions:
contents: write
env:
VERSION: ${{ inputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Update version files
run: python scripts/update_version.py "$VERSION"
- uses: actions/download-artifact@v4
with:
path: dist
pattern: wheel-*
merge-multiple: true
- name: Verify all expected wheels are present
run: |
set -euo pipefail
ls -la dist/
expected=(
"macosx_11_0_arm64"
"macosx_11_0_x86_64"
"manylinux_2_17_x86_64"
"manylinux_2_17_aarch64"
"win_amd64"
)
for tag in "${expected[@]}"; do
if ! ls dist/*"${tag}".whl 2>/dev/null; then
echo "::error::Missing wheel for platform tag: ${tag}"
exit 1
fi
done
echo "All ${#expected[@]} expected wheels present ✓"
- name: Build sdist and publish to PyPI
run: |
pip install build twine
python -m build --sdist
twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
- name: Configure git
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- name: Commit version changes
run: |
git add pyproject.toml src/claude_agent_sdk/_version.py
git commit -m "chore: release v$VERSION"
- name: Update changelog with Claude
continue-on-error: true
uses: anthropics/claude-code-action@v1
with:
prompt: "/generate-changelog new version: ${{ env.VERSION }}, old version: ${{ inputs.previous_tag }}"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
claude_args: |
--model claude-opus-4-6
--allowedTools 'Bash(git add:*),Bash(git commit:*),Edit'
- name: Push to main
run: |
git remote set-url origin git@github.com:anthropics/claude-agent-sdk-python.git
git push origin main
- name: Create tag and GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
awk -v ver="$VERSION" '/^## / { if (found) exit; if ($2 == ver) found=1; next } found { print }' CHANGELOG.md > release_notes.md
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
gh release create "v$VERSION" --title "v$VERSION" --notes-file release_notes.md