mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-12-23 09:19:52 +00:00
Some checks are pending
Lint / lint (push) Waiting to run
Test / test (macos-latest, 3.12) (push) Waiting to run
Test / test (macos-latest, 3.10) (push) Waiting to run
Test / test (ubuntu-latest, 3.10) (push) Waiting to run
Test / test (ubuntu-latest, 3.11) (push) Waiting to run
Test / test (ubuntu-latest, 3.12) (push) Waiting to run
Test / test (ubuntu-latest, 3.13) (push) Waiting to run
Test / test-e2e (macos-latest, 3.11) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.11) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.12) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.13) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.12) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.13) (push) Blocked by required conditions
Test / test (macos-latest, 3.11) (push) Waiting to run
Test / test (macos-latest, 3.13) (push) Waiting to run
Test / test (windows-latest, 3.10) (push) Waiting to run
Test / test (windows-latest, 3.11) (push) Waiting to run
Test / test (windows-latest, 3.12) (push) Waiting to run
Test / test (windows-latest, 3.13) (push) Waiting to run
Test / test-e2e (macos-latest, 3.10) (push) Blocked by required conditions
Test / test-e2e (macos-latest, 3.12) (push) Blocked by required conditions
Test / test-e2e (macos-latest, 3.13) (push) Blocked by required conditions
Test / test-e2e (ubuntu-latest, 3.10) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.10) (push) Blocked by required conditions
Test / test-e2e (windows-latest, 3.11) (push) Blocked by required conditions
Test / test-examples (3.13) (push) Blocked by required conditions
The fetch-depth: 0 was on build-wheels but changelog generation happens in the publish job. Moved it to the correct location and upgraded the model for better changelog generation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
222 lines
6.3 KiB
YAML
222 lines
6.3 KiB
YAML
name: Publish to PyPI
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Package version to publish (e.g., 0.1.4)'
|
|
required: true
|
|
type: string
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -e ".[dev]"
|
|
|
|
- name: Run tests
|
|
run: |
|
|
python -m pytest tests/ -v
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -e ".[dev]"
|
|
|
|
- name: Run ruff
|
|
run: |
|
|
ruff check src/ tests/
|
|
ruff format --check src/ tests/
|
|
|
|
- name: Run mypy
|
|
run: |
|
|
mypy src/
|
|
|
|
build-wheels:
|
|
needs: [test, lint]
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install build twine wheel
|
|
shell: bash
|
|
|
|
- name: Build wheel with bundled CLI
|
|
run: |
|
|
python scripts/build_wheel.py \
|
|
--version "${{ github.event.inputs.version }}" \
|
|
--skip-sdist \
|
|
--clean
|
|
shell: bash
|
|
|
|
- name: Upload wheel artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheel-${{ matrix.os }}
|
|
path: dist/*.whl
|
|
if-no-files-found: error
|
|
compression-level: 0
|
|
|
|
publish:
|
|
needs: [build-wheels]
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
fetch-depth: 0 # Fetch all history including tags for changelog generation
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Set version
|
|
id: version
|
|
run: |
|
|
VERSION="${{ github.event.inputs.version }}"
|
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Update version
|
|
run: |
|
|
python scripts/update_version.py "${{ env.VERSION }}"
|
|
|
|
- name: Read CLI version from code
|
|
id: cli_version
|
|
run: |
|
|
CLI_VERSION=$(python -c "import re; print(re.search(r'__cli_version__ = \"([^\"]+)\"', open('src/claude_agent_sdk/_cli_version.py').read()).group(1))")
|
|
echo "cli_version=$CLI_VERSION" >> $GITHUB_OUTPUT
|
|
echo "Bundled CLI version: $CLI_VERSION"
|
|
|
|
- name: Download all wheel artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: dist
|
|
pattern: wheel-*
|
|
merge-multiple: true
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install build twine
|
|
|
|
- name: Build source distribution
|
|
run: python -m build --sdist
|
|
|
|
- name: Publish to PyPI
|
|
env:
|
|
TWINE_USERNAME: __token__
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
run: |
|
|
twine upload dist/*
|
|
echo "Package published to PyPI"
|
|
echo "Install with: pip install claude-agent-sdk==${{ env.VERSION }}"
|
|
|
|
- name: Get previous release tag
|
|
id: previous_tag
|
|
run: |
|
|
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
|
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
|
|
echo "Previous release: $PREVIOUS_TAG"
|
|
|
|
- name: Create release branch and commit version changes
|
|
run: |
|
|
# Create a new branch for the version update
|
|
BRANCH_NAME="release/v${{ env.VERSION }}"
|
|
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
|
|
|
|
# Configure git
|
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
|
git config --local user.name "github-actions[bot]"
|
|
|
|
# Create and switch to new branch
|
|
git checkout -b "$BRANCH_NAME"
|
|
|
|
# Commit version changes
|
|
git add pyproject.toml src/claude_agent_sdk/_version.py
|
|
git commit -m "chore: release v${{ env.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: ${{ steps.previous_tag.outputs.previous_tag }}"
|
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
claude_args: |
|
|
--model claude-opus-4-5
|
|
--allowedTools 'Bash(git add:*),Bash(git commit:*),Edit'
|
|
|
|
- name: Push branch and create PR
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
# Push the branch with all commits
|
|
git push origin "${{ env.BRANCH_NAME }}"
|
|
|
|
# Create PR using GitHub CLI
|
|
PR_BODY="This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
|
|
|
|
## Changes
|
|
- Updated version in \`pyproject.toml\` to ${{ env.VERSION }}
|
|
- Updated version in \`src/claude_agent_sdk/_version.py\` to ${{ env.VERSION }}
|
|
- Updated \`CHANGELOG.md\` with release notes
|
|
|
|
## Release Information
|
|
- Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ env.VERSION }}/
|
|
- Bundled CLI version: ${{ steps.cli_version.outputs.cli_version }}
|
|
- Install with: \`pip install claude-agent-sdk==${{ env.VERSION }}\`
|
|
|
|
🤖 Generated by GitHub Actions"
|
|
|
|
PR_URL=$(gh pr create \
|
|
--title "chore: release v${{ env.VERSION }}" \
|
|
--body "$PR_BODY" \
|
|
--base main \
|
|
--head "${{ env.BRANCH_NAME }}")
|
|
|
|
echo "PR created: $PR_URL"
|