mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-07-07 14:45:00 +00:00
feat: automate version updates after PyPI release
- Update publish.yml to create PR after publishing - Add create-release-tag.yml to tag releases when PR merges - Eliminates manual version syncing between repo and PyPI
This commit is contained in:
parent
9bda4e8982
commit
149142c960
2 changed files with 102 additions and 1 deletions
59
.github/workflows/create-release-tag.yml
vendored
Normal file
59
.github/workflows/create-release-tag.yml
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
name: Create Release Tag
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-tag:
|
||||||
|
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Extract version from branch name
|
||||||
|
id: extract_version
|
||||||
|
run: |
|
||||||
|
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
|
||||||
|
VERSION="${BRANCH_NAME#release/v}"
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create and push tag
|
||||||
|
run: |
|
||||||
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --local user.name "github-actions[bot]"
|
||||||
|
|
||||||
|
# Create annotated tag
|
||||||
|
git tag -a "v${{ steps.extract_version.outputs.version }}" \
|
||||||
|
-m "Release v${{ steps.extract_version.outputs.version }}"
|
||||||
|
|
||||||
|
# Push tag
|
||||||
|
git push origin "v${{ steps.extract_version.outputs.version }}"
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: v${{ steps.extract_version.outputs.version }}
|
||||||
|
release_name: Release v${{ steps.extract_version.outputs.version }}
|
||||||
|
body: |
|
||||||
|
## Release v${{ steps.extract_version.outputs.version }}
|
||||||
|
|
||||||
|
Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ steps.extract_version.outputs.version }}/
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
```bash
|
||||||
|
pip install claude-code-sdk==${{ steps.extract_version.outputs.version }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### What's Changed
|
||||||
|
See the [full changelog](https://github.com/${{ github.repository }}/compare/v${{ steps.extract_version.outputs.version }}...v${{ steps.extract_version.outputs.version }})
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
44
.github/workflows/publish.yml
vendored
44
.github/workflows/publish.yml
vendored
|
@ -65,9 +65,14 @@ jobs:
|
||||||
publish:
|
publish:
|
||||||
needs: [test, lint]
|
needs: [test, lint]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
|
@ -108,4 +113,41 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
twine upload dist/*
|
twine upload dist/*
|
||||||
echo "Package published to PyPI"
|
echo "Package published to PyPI"
|
||||||
echo "Install with: pip install claude-code-sdk==${{ github.event.inputs.version }}"
|
echo "Install with: pip install claude-code-sdk==${{ github.event.inputs.version }}"
|
||||||
|
|
||||||
|
- name: Create version update PR
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
# Create a new branch for the version update
|
||||||
|
BRANCH_NAME="release/v${{ github.event.inputs.version }}"
|
||||||
|
git checkout -b "$BRANCH_NAME"
|
||||||
|
|
||||||
|
# Configure git
|
||||||
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --local user.name "github-actions[bot]"
|
||||||
|
|
||||||
|
# Commit the version changes
|
||||||
|
git add pyproject.toml src/claude_code_sdk/__init__.py
|
||||||
|
git commit -m "chore: bump version to ${{ github.event.inputs.version }}"
|
||||||
|
|
||||||
|
# Push the branch
|
||||||
|
git push origin "$BRANCH_NAME"
|
||||||
|
|
||||||
|
# Create PR using GitHub CLI (gh)
|
||||||
|
gh pr create \
|
||||||
|
--title "chore: bump version to ${{ github.event.inputs.version }}" \
|
||||||
|
--body "This PR updates the version to ${{ github.event.inputs.version }} after publishing to PyPI.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
- Updated version in \`pyproject.toml\`
|
||||||
|
- Updated version in \`src/claude_code_sdk/__init__.py\`
|
||||||
|
|
||||||
|
## Release Information
|
||||||
|
- Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ github.event.inputs.version }}/
|
||||||
|
- Install with: \`pip install claude-code-sdk==${{ github.event.inputs.version }}\`
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
After merging this PR, a release tag will be created automatically." \
|
||||||
|
--base main \
|
||||||
|
--head "$BRANCH_NAME"
|
Loading…
Add table
Add a link
Reference in a new issue