Skip to content

Commit b1d3c78

Browse files
ashwin-antclaude
andcommitted
feat: automate changelog updates in release workflow
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>
1 parent c2b72f1 commit b1d3c78

File tree

1 file changed

+58
-46
lines changed

1 file changed

+58
-46
lines changed

.github/workflows/publish.yml

Lines changed: 58 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -104,66 +104,78 @@ 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-
-F content=@pyproject.toml.b64 \
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-
-F content=@version.py.b64 \
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+
uses: anthropics/claude-code-action@v1
133+
with:
134+
prompt: |
135+
You are updating the changelog for the new release v${{ env.VERSION }}.
136+
137+
Update CHANGELOG.md to add a new section for version ${{ env.VERSION }} at the top of the file, right after the '# Changelog' heading.
138+
139+
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:
140+
- Breaking Changes (if any)
141+
- New Features
142+
- Bug Fixes
143+
- Documentation
144+
- Internal/Other changes
145+
146+
Include only the sections that are relevant based on the actual changes. Write clear, user-focused descriptions.
147+
148+
After updating CHANGELOG.md, commit the changes with the message "docs: update changelog for v${{ env.VERSION }}".
149+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
150+
github_token: ${{ secrets.GITHUB_TOKEN }}
151+
claude_args: |
152+
--allowedTools 'Bash(git add:*),Bash(git commit:*),Edit'
153+
154+
- name: Push branch and create PR
155+
env:
156+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
run: |
158+
# Push the branch with all commits
159+
git push origin "${{ env.BRANCH_NAME }}"
160+
150161
# Create PR using GitHub CLI
151162
PR_BODY="This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
152-
163+
153164
## Changes
154165
- Updated version in \`pyproject.toml\`
155166
- Updated version in \`src/claude_agent_sdk/_version.py\`
156-
167+
- Updated \`CHANGELOG.md\` with release notes
168+
157169
## Release Information
158170
- Published to PyPI: https://pypi.org/project/claude-agent-sdk/${{ env.VERSION }}/
159171
- Install with: \`pip install claude-agent-sdk==${{ env.VERSION }}\`
160-
172+
161173
🤖 Generated by GitHub Actions"
162-
174+
163175
PR_URL=$(gh pr create \
164-
--title "chore: bump version to ${{ env.VERSION }}" \
176+
--title "chore: release v${{ env.VERSION }}" \
165177
--body "$PR_BODY" \
166178
--base main \
167-
--head "$BRANCH_NAME")
168-
179+
--head "${{ env.BRANCH_NAME }}")
180+
169181
echo "PR created: $PR_URL"

0 commit comments

Comments
 (0)