Skip to content

Commit b3c20bd

Browse files
authored
Merge pull request anthropics#46 from anthropics/automated-version-update-workflow
feat: automate version updates after PyPI release
2 parents 9bda4e8 + 149142c commit b3c20bd

File tree

2 files changed

+102
-1
lines changed

2 files changed

+102
-1
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Create Release Tag
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
create-tag:
10+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Extract version from branch name
21+
id: extract_version
22+
run: |
23+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
24+
VERSION="${BRANCH_NAME#release/v}"
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
27+
- name: Create and push tag
28+
run: |
29+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
30+
git config --local user.name "github-actions[bot]"
31+
32+
# Create annotated tag
33+
git tag -a "v${{ steps.extract_version.outputs.version }}" \
34+
-m "Release v${{ steps.extract_version.outputs.version }}"
35+
36+
# Push tag
37+
git push origin "v${{ steps.extract_version.outputs.version }}"
38+
39+
- name: Create GitHub Release
40+
uses: actions/create-release@v1
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
with:
44+
tag_name: v${{ steps.extract_version.outputs.version }}
45+
release_name: Release v${{ steps.extract_version.outputs.version }}
46+
body: |
47+
## Release v${{ steps.extract_version.outputs.version }}
48+
49+
Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ steps.extract_version.outputs.version }}/
50+
51+
### Installation
52+
```bash
53+
pip install claude-code-sdk==${{ steps.extract_version.outputs.version }}
54+
```
55+
56+
### What's Changed
57+
See the [full changelog](https://github.com/${{ github.repository }}/compare/v${{ steps.extract_version.outputs.version }}...v${{ steps.extract_version.outputs.version }})
58+
draft: false
59+
prerelease: false

.github/workflows/publish.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ jobs:
6565
publish:
6666
needs: [test, lint]
6767
runs-on: ubuntu-latest
68+
permissions:
69+
contents: write
70+
pull-requests: write
6871

6972
steps:
7073
- uses: actions/checkout@v4
74+
with:
75+
token: ${{ secrets.GITHUB_TOKEN }}
7176

7277
- name: Set up Python
7378
uses: actions/setup-python@v5
@@ -108,4 +113,41 @@ jobs:
108113
run: |
109114
twine upload dist/*
110115
echo "Package published to PyPI"
111-
echo "Install with: pip install claude-code-sdk==${{ github.event.inputs.version }}"
116+
echo "Install with: pip install claude-code-sdk==${{ github.event.inputs.version }}"
117+
118+
- name: Create version update PR
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
run: |
122+
# Create a new branch for the version update
123+
BRANCH_NAME="release/v${{ github.event.inputs.version }}"
124+
git checkout -b "$BRANCH_NAME"
125+
126+
# Configure git
127+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
128+
git config --local user.name "github-actions[bot]"
129+
130+
# Commit the version changes
131+
git add pyproject.toml src/claude_code_sdk/__init__.py
132+
git commit -m "chore: bump version to ${{ github.event.inputs.version }}"
133+
134+
# Push the branch
135+
git push origin "$BRANCH_NAME"
136+
137+
# Create PR using GitHub CLI (gh)
138+
gh pr create \
139+
--title "chore: bump version to ${{ github.event.inputs.version }}" \
140+
--body "This PR updates the version to ${{ github.event.inputs.version }} after publishing to PyPI.
141+
142+
## Changes
143+
- Updated version in \`pyproject.toml\`
144+
- Updated version in \`src/claude_code_sdk/__init__.py\`
145+
146+
## Release Information
147+
- Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ github.event.inputs.version }}/
148+
- Install with: \`pip install claude-code-sdk==${{ github.event.inputs.version }}\`
149+
150+
## Next Steps
151+
After merging this PR, a release tag will be created automatically." \
152+
--base main \
153+
--head "$BRANCH_NAME"

0 commit comments

Comments
 (0)