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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue