mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-12-23 09:19:52 +00:00
feat: automate changelog updates in release workflow (#231)
Replace GitHub API-based commits with local git workflow and integrate claude-code-action to automatically generate changelog entries. The workflow now: - Creates release branch locally with version commits - Uses Claude to review changes and update CHANGELOG.md - Pushes complete branch with all commits together 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c2b72f1cc5
commit
71a85ac9aa
2 changed files with 72 additions and 56 deletions
101
.github/workflows/publish.yml
vendored
101
.github/workflows/publish.yml
vendored
|
|
@ -104,66 +104,79 @@ jobs:
|
|||
echo "Package published to PyPI"
|
||||
echo "Install with: pip install claude-agent-sdk==${{ env.VERSION }}"
|
||||
|
||||
- name: Create version update PR
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- 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
|
||||
|
||||
# Create branch via API
|
||||
BASE_SHA=$(git rev-parse HEAD)
|
||||
gh api \
|
||||
--method POST \
|
||||
/repos/$GITHUB_REPOSITORY/git/refs \
|
||||
-f ref="refs/heads/$BRANCH_NAME" \
|
||||
-f sha="$BASE_SHA"
|
||||
|
||||
# Get current SHA values of files
|
||||
echo "Getting SHA for pyproject.toml"
|
||||
PYPROJECT_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/pyproject.toml --jq '.sha')
|
||||
echo "Getting SHA for _version.py"
|
||||
VERSION_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/src/claude_agent_sdk/_version.py --jq '.sha')
|
||||
|
||||
# Commit pyproject.toml via GitHub API (this creates signed commits)
|
||||
message="chore: bump version to ${{ env.VERSION }}"
|
||||
base64 -i pyproject.toml > pyproject.toml.b64
|
||||
gh api \
|
||||
--method PUT \
|
||||
/repos/$GITHUB_REPOSITORY/contents/pyproject.toml \
|
||||
-f message="$message" \
|
||||
-F content=@pyproject.toml.b64 \
|
||||
-f sha="$PYPROJECT_SHA" \
|
||||
-f branch="$BRANCH_NAME"
|
||||
# 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: bump version to ${{ env.VERSION }}"
|
||||
|
||||
- name: Update changelog with Claude
|
||||
continue-on-error: true
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
prompt: |
|
||||
You are updating the changelog for the new release v${{ env.VERSION }}.
|
||||
|
||||
Update CHANGELOG.md to add a new section for version ${{ env.VERSION }} at the top of the file, right after the '# Changelog' heading.
|
||||
|
||||
Review the recent commits and merged pull requests since the last release (${{ steps.previous_tag.outputs.previous_tag }}) to generate meaningful changelog content for v${{ env.VERSION }}. Follow the existing format in CHANGELOG.md with sections like:
|
||||
- Breaking Changes (if any)
|
||||
- New Features
|
||||
- Bug Fixes
|
||||
- Documentation
|
||||
- Internal/Other changes
|
||||
|
||||
Include only the sections that are relevant based on the actual changes. Write clear, user-focused descriptions.
|
||||
|
||||
After updating CHANGELOG.md, commit the changes with the message "docs: update changelog for v${{ env.VERSION }}".
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
claude_args: |
|
||||
--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 }}"
|
||||
|
||||
# Commit _version.py via GitHub API
|
||||
base64 -i src/claude_agent_sdk/_version.py > version.py.b64
|
||||
gh api \
|
||||
--method PUT \
|
||||
/repos/$GITHUB_REPOSITORY/contents/src/claude_agent_sdk/_version.py \
|
||||
-f message="$message" \
|
||||
-F content=@version.py.b64 \
|
||||
-f sha="$VERSION_SHA" \
|
||||
-f branch="$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\`
|
||||
- Updated version in \`src/claude_agent_sdk/_version.py\`
|
||||
|
||||
- Updated \`CHANGELOG.md\` with release notes
|
||||
|
||||
## Release Information
|
||||
- Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ env.VERSION }}/
|
||||
- Install with: \`pip install claude-agent-sdk==${{ env.VERSION }}\`
|
||||
|
||||
|
||||
🤖 Generated by GitHub Actions"
|
||||
|
||||
|
||||
PR_URL=$(gh pr create \
|
||||
--title "chore: bump version to ${{ env.VERSION }}" \
|
||||
--title "chore: release v${{ env.VERSION }}" \
|
||||
--body "$PR_BODY" \
|
||||
--base main \
|
||||
--head "$BRANCH_NAME")
|
||||
|
||||
--head "${{ env.BRANCH_NAME }}")
|
||||
|
||||
echo "PR created: $PR_URL"
|
||||
27
CHANGELOG.md
27
CHANGELOG.md
|
|
@ -1,5 +1,16 @@
|
|||
# Changelog
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Features
|
||||
|
||||
- **Minimum Claude Code version check**: Added version validation to ensure Claude Code 2.0.0+ is installed. The SDK will display a warning if an older version is detected, helping prevent compatibility issues
|
||||
- **Updated PermissionResult types**: Aligned permission result types with the latest control protocol for better type safety and compatibility
|
||||
|
||||
### Improvements
|
||||
|
||||
- **Model references**: Updated all examples and tests to use the simplified `claude-sonnet-4-5` model identifier instead of dated version strings
|
||||
|
||||
## 0.1.0
|
||||
|
||||
Introducing the Claude Agent SDK! The Claude Code SDK has been renamed to better reflect its capabilities for building AI agents across all domains, not just coding.
|
||||
|
|
@ -7,7 +18,9 @@ Introducing the Claude Agent SDK! The Claude Code SDK has been renamed to better
|
|||
### Breaking Changes
|
||||
|
||||
#### Type Name Changes
|
||||
|
||||
- **ClaudeCodeOptions renamed to ClaudeAgentOptions**: The options type has been renamed to match the new SDK branding. Update all imports and type references:
|
||||
|
||||
```python
|
||||
# Before
|
||||
from claude_agent_sdk import query, ClaudeCodeOptions
|
||||
|
|
@ -19,6 +32,7 @@ Introducing the Claude Agent SDK! The Claude Code SDK has been renamed to better
|
|||
```
|
||||
|
||||
#### System Prompt Changes
|
||||
|
||||
- **Merged prompt options**: The `custom_system_prompt` and `append_system_prompt` fields have been merged into a single `system_prompt` field for simpler configuration
|
||||
- **No default system prompt**: The Claude Code system prompt is no longer included by default, giving you full control over agent behavior. To use the Claude Code system prompt, explicitly set:
|
||||
```python
|
||||
|
|
@ -26,6 +40,7 @@ Introducing the Claude Agent SDK! The Claude Code SDK has been renamed to better
|
|||
```
|
||||
|
||||
#### Settings Isolation
|
||||
|
||||
- **No filesystem settings by default**: Settings files (`settings.json`, `CLAUDE.md`), slash commands, and subagents are no longer loaded automatically. This ensures SDK applications have predictable behavior independent of local filesystem configurations
|
||||
- **Explicit settings control**: Use the new `setting_sources` field to specify which settings locations to load: `["user", "project", "local"]`
|
||||
|
||||
|
|
@ -43,17 +58,6 @@ For full migration instructions, see our [migration guide](https://docs.claude.c
|
|||
- New guides for [Custom Tools](https://docs.claude.com/en/api/agent-sdk/custom-tools), [Permissions](https://docs.claude.com/en/api/agent-sdk/permissions), [Session Management](https://docs.claude.com/en/api/agent-sdk/sessions), and more
|
||||
- Complete [Python API reference](https://docs.claude.com/en/api/agent-sdk/python)
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Features
|
||||
|
||||
- **Minimum Claude Code version check**: Added version validation to ensure Claude Code 2.0.0+ is installed. The SDK will display a warning if an older version is detected, helping prevent compatibility issues
|
||||
- **Updated PermissionResult types**: Aligned permission result types with the latest control protocol for better type safety and compatibility
|
||||
|
||||
### Improvements
|
||||
|
||||
- **Model references**: Updated all examples and tests to use the simplified `claude-sonnet-4-5` model identifier instead of dated version strings
|
||||
|
||||
## 0.0.22
|
||||
|
||||
- Introduce custom tools, implemented as in-process MCP servers.
|
||||
|
|
@ -91,4 +95,3 @@ For full migration instructions, see our [migration guide](https://docs.claude.c
|
|||
- Fix multi-line buffering issue
|
||||
- Rename cost_usd to total_cost_usd in API responses
|
||||
- Fix optional cost fields handling
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue