Skip to content

Commit 71a85ac

Browse files
ashwin-antclaude
andauthored
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 <[email protected]>
1 parent c2b72f1 commit 71a85ac

File tree

2 files changed

+74
-58
lines changed

2 files changed

+74
-58
lines changed

.github/workflows/publish.yml

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -104,66 +104,79 @@ jobs:
104104
echo "Package published to PyPI"
105105
echo "Install with: pip install claude-agent-sdk==${{ env.VERSION }}"
106106
107-
- name: Create version update PR
108-
env:
109-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
- name: Get previous release tag
108+
id: previous_tag
109+
run: |
110+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
111+
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
112+
echo "Previous release: $PREVIOUS_TAG"
113+
114+
- name: Create release branch and commit version changes
110115
run: |
111116
# Create a new branch for the version update
112117
BRANCH_NAME="release/v${{ env.VERSION }}"
113118
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
114-
115-
# Create branch via API
116-
BASE_SHA=$(git rev-parse HEAD)
117-
gh api \
118-
--method POST \
119-
/repos/$GITHUB_REPOSITORY/git/refs \
120-
-f ref="refs/heads/$BRANCH_NAME" \
121-
-f sha="$BASE_SHA"
122-
123-
# Get current SHA values of files
124-
echo "Getting SHA for pyproject.toml"
125-
PYPROJECT_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/pyproject.toml --jq '.sha')
126-
echo "Getting SHA for _version.py"
127-
VERSION_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/src/claude_agent_sdk/_version.py --jq '.sha')
128-
129-
# Commit pyproject.toml via GitHub API (this creates signed commits)
130-
message="chore: bump version to ${{ env.VERSION }}"
131-
base64 -i pyproject.toml > pyproject.toml.b64
132-
gh api \
133-
--method PUT \
134-
/repos/$GITHUB_REPOSITORY/contents/pyproject.toml \
135-
-f message="$message" \
136-
137-
-f sha="$PYPROJECT_SHA" \
138-
-f branch="$BRANCH_NAME"
139-
140-
# Commit _version.py via GitHub API
141-
base64 -i src/claude_agent_sdk/_version.py > version.py.b64
142-
gh api \
143-
--method PUT \
144-
/repos/$GITHUB_REPOSITORY/contents/src/claude_agent_sdk/_version.py \
145-
-f message="$message" \
146-
147-
-f sha="$VERSION_SHA" \
148-
-f branch="$BRANCH_NAME"
149-
119+
120+
# Configure git
121+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
122+
git config --local user.name "github-actions[bot]"
123+
124+
# Create and switch to new branch
125+
git checkout -b "$BRANCH_NAME"
126+
127+
# Commit version changes
128+
git add pyproject.toml src/claude_agent_sdk/_version.py
129+
git commit -m "chore: bump version to ${{ env.VERSION }}"
130+
131+
- name: Update changelog with Claude
132+
continue-on-error: true
133+
uses: anthropics/claude-code-action@v1
134+
with:
135+
prompt: |
136+
You are updating the changelog for the new release v${{ env.VERSION }}.
137+
138+
Update CHANGELOG.md to add a new section for version ${{ env.VERSION }} at the top of the file, right after the '# Changelog' heading.
139+
140+
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:
141+
- Breaking Changes (if any)
142+
- New Features
143+
- Bug Fixes
144+
- Documentation
145+
- Internal/Other changes
146+
147+
Include only the sections that are relevant based on the actual changes. Write clear, user-focused descriptions.
148+
149+
After updating CHANGELOG.md, commit the changes with the message "docs: update changelog for v${{ env.VERSION }}".
150+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
151+
github_token: ${{ secrets.GITHUB_TOKEN }}
152+
claude_args: |
153+
--allowedTools 'Bash(git add:*),Bash(git commit:*),Edit'
154+
155+
- name: Push branch and create PR
156+
env:
157+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
run: |
159+
# Push the branch with all commits
160+
git push origin "${{ env.BRANCH_NAME }}"
161+
150162
# Create PR using GitHub CLI
151163
PR_BODY="This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
152-
164+
153165
## Changes
154166
- Updated version in \`pyproject.toml\`
155167
- Updated version in \`src/claude_agent_sdk/_version.py\`
156-
168+
- Updated \`CHANGELOG.md\` with release notes
169+
157170
## Release Information
158171
- Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ env.VERSION }}/
159172
- Install with: \`pip install claude-agent-sdk==${{ env.VERSION }}\`
160-
173+
161174
🤖 Generated by GitHub Actions"
162-
175+
163176
PR_URL=$(gh pr create \
164-
--title "chore: bump version to ${{ env.VERSION }}" \
177+
--title "chore: release v${{ env.VERSION }}" \
165178
--body "$PR_BODY" \
166179
--base main \
167-
--head "$BRANCH_NAME")
168-
180+
--head "${{ env.BRANCH_NAME }}")
181+
169182
echo "PR created: $PR_URL"

CHANGELOG.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
# Changelog
22

3+
## 0.1.1
4+
5+
### Features
6+
7+
- **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
8+
- **Updated PermissionResult types**: Aligned permission result types with the latest control protocol for better type safety and compatibility
9+
10+
### Improvements
11+
12+
- **Model references**: Updated all examples and tests to use the simplified `claude-sonnet-4-5` model identifier instead of dated version strings
13+
314
## 0.1.0
415

516
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.
617

718
### Breaking Changes
819

920
#### Type Name Changes
21+
1022
- **ClaudeCodeOptions renamed to ClaudeAgentOptions**: The options type has been renamed to match the new SDK branding. Update all imports and type references:
23+
1124
```python
1225
# Before
1326
from claude_agent_sdk import query, ClaudeCodeOptions
@@ -19,13 +32,15 @@ Introducing the Claude Agent SDK! The Claude Code SDK has been renamed to better
1932
```
2033

2134
#### System Prompt Changes
35+
2236
- **Merged prompt options**: The `custom_system_prompt` and `append_system_prompt` fields have been merged into a single `system_prompt` field for simpler configuration
2337
- **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:
2438
```python
2539
system_prompt={"type": "preset", "preset": "claude_code"}
2640
```
2741

2842
#### Settings Isolation
43+
2944
- **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
3045
- **Explicit settings control**: Use the new `setting_sources` field to specify which settings locations to load: `["user", "project", "local"]`
3146

@@ -43,17 +58,6 @@ For full migration instructions, see our [migration guide](https://docs.claude.c
4358
- 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
4459
- Complete [Python API reference](https://docs.claude.com/en/api/agent-sdk/python)
4560

46-
## 0.1.1
47-
48-
### Features
49-
50-
- **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
51-
- **Updated PermissionResult types**: Aligned permission result types with the latest control protocol for better type safety and compatibility
52-
53-
### Improvements
54-
55-
- **Model references**: Updated all examples and tests to use the simplified `claude-sonnet-4-5` model identifier instead of dated version strings
56-
5761
## 0.0.22
5862

5963
- 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
9195
- Fix multi-line buffering issue
9296
- Rename cost_usd to total_cost_usd in API responses
9397
- Fix optional cost fields handling
94-

0 commit comments

Comments
 (0)