Try again

This commit is contained in:
Dickson Tsai 2025-07-21 09:39:49 -07:00
parent 4eb3a1f955
commit 5c120a30ff
No known key found for this signature in database

View file

@ -9,7 +9,7 @@ on:
description: 'Version to publish (e.g., 0.1.0)'
required: true
type: string
default: '0.0.0.dev20250121' # TESTING ONLY - REMOVE BEFORE MERGE
default: '0.0.0.dev20250721' # TESTING ONLY - REMOVE BEFORE MERGE
jobs:
test:
runs-on: ubuntu-latest
@ -79,7 +79,7 @@ jobs:
- name: Set version
id: version
run: |
VERSION="${{ github.event.inputs.version || '0.0.0.dev20250121' }}" # TESTING ONLY - defaults to test version
VERSION="${{ github.event.inputs.version || '0.0.0.dev20250721' }}" # TESTING ONLY - defaults to test version
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
@ -109,21 +109,49 @@ jobs:
- name: Create version update PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create a new branch for the version update
BRANCH_NAME="release/v${{ env.VERSION }}"
git checkout -b "$BRANCH_NAME"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
# Configure git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# 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"
# Commit the version changes
git add pyproject.toml src/claude_code_sdk/__init__.py
git commit -m "chore: bump version to ${{ env.VERSION }}
# 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 __init__.py"
INIT_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/src/claude_code_sdk/__init__.py --jq '.sha')
This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
# 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"
# Commit __init__.py via GitHub API
base64 -i src/claude_code_sdk/__init__.py > init.py.b64
gh api \
--method PUT \
/repos/$GITHUB_REPOSITORY/contents/src/claude_code_sdk/__init__.py \
-f message="$message" \
-F content=@init.py.b64 \
-f sha="$INIT_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\`
@ -133,17 +161,12 @@ jobs:
- Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ env.VERSION }}/
- Install with: \`pip install claude-code-sdk==${{ env.VERSION }}\`
## Next Steps
After merging this PR, a release tag will be created automatically.
🤖 Generated by GitHub Actions"
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
# Push the branch
git push origin "$BRANCH_NAME"
# Create PR using GitHub CLI (gh)
gh pr create \
PR_URL=$(gh pr create \
--title "chore: bump version to ${{ env.VERSION }}" \
--body "Automated PR to update version after PyPI release." \
--body "$PR_BODY" \
--base main \
--head "$BRANCH_NAME"
--head "$BRANCH_NAME")
echo "PR created: $PR_URL"