Skip to content

Commit 5c120a3

Browse files
committed
Try again
1 parent 4eb3a1f commit 5c120a3

1 file changed

Lines changed: 45 additions & 22 deletions

File tree

.github/workflows/publish.yml

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
description: 'Version to publish (e.g., 0.1.0)'
1010
required: true
1111
type: string
12-
default: '0.0.0.dev20250121' # TESTING ONLY - REMOVE BEFORE MERGE
12+
default: '0.0.0.dev20250721' # TESTING ONLY - REMOVE BEFORE MERGE
1313
jobs:
1414
test:
1515
runs-on: ubuntu-latest
@@ -79,7 +79,7 @@ jobs:
7979
- name: Set version
8080
id: version
8181
run: |
82-
VERSION="${{ github.event.inputs.version || '0.0.0.dev20250121' }}" # TESTING ONLY - defaults to test version
82+
VERSION="${{ github.event.inputs.version || '0.0.0.dev20250721' }}" # TESTING ONLY - defaults to test version
8383
echo "VERSION=$VERSION" >> $GITHUB_ENV
8484
echo "version=$VERSION" >> $GITHUB_OUTPUT
8585
@@ -109,21 +109,49 @@ jobs:
109109
110110
- name: Create version update PR
111111
env:
112-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113113
run: |
114114
# Create a new branch for the version update
115115
BRANCH_NAME="release/v${{ env.VERSION }}"
116-
git checkout -b "$BRANCH_NAME"
116+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
117117
118-
# Configure git
119-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
120-
git config --local user.name "github-actions[bot]"
118+
# Create branch via API
119+
BASE_SHA=$(git rev-parse HEAD)
120+
gh api \
121+
--method POST \
122+
/repos/$GITHUB_REPOSITORY/git/refs \
123+
-f ref="refs/heads/$BRANCH_NAME" \
124+
-f sha="$BASE_SHA"
121125
122-
# Commit the version changes
123-
git add pyproject.toml src/claude_code_sdk/__init__.py
124-
git commit -m "chore: bump version to ${{ env.VERSION }}
126+
# Get current SHA values of files
127+
echo "Getting SHA for pyproject.toml"
128+
PYPROJECT_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/pyproject.toml --jq '.sha')
129+
echo "Getting SHA for __init__.py"
130+
INIT_SHA=$(gh api /repos/$GITHUB_REPOSITORY/contents/src/claude_code_sdk/__init__.py --jq '.sha')
125131
126-
This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
132+
# Commit pyproject.toml via GitHub API (this creates signed commits)
133+
message="chore: bump version to ${{ env.VERSION }}"
134+
base64 -i pyproject.toml > pyproject.toml.b64
135+
gh api \
136+
--method PUT \
137+
/repos/$GITHUB_REPOSITORY/contents/pyproject.toml \
138+
-f message="$message" \
139+
-F content=@pyproject.toml.b64 \
140+
-f sha="$PYPROJECT_SHA" \
141+
-f branch="$BRANCH_NAME"
142+
143+
# Commit __init__.py via GitHub API
144+
base64 -i src/claude_code_sdk/__init__.py > init.py.b64
145+
gh api \
146+
--method PUT \
147+
/repos/$GITHUB_REPOSITORY/contents/src/claude_code_sdk/__init__.py \
148+
-f message="$message" \
149+
-F content=@init.py.b64 \
150+
-f sha="$INIT_SHA" \
151+
-f branch="$BRANCH_NAME"
152+
153+
# Create PR using GitHub CLI
154+
PR_BODY="This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
127155
128156
## Changes
129157
- Updated version in \`pyproject.toml\`
@@ -133,17 +161,12 @@ jobs:
133161
- Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ env.VERSION }}/
134162
- Install with: \`pip install claude-code-sdk==${{ env.VERSION }}\`
135163
136-
## Next Steps
137-
After merging this PR, a release tag will be created automatically.
138-
139-
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
164+
🤖 Generated by GitHub Actions"
140165
141-
# Push the branch
142-
git push origin "$BRANCH_NAME"
143-
144-
# Create PR using GitHub CLI (gh)
145-
gh pr create \
166+
PR_URL=$(gh pr create \
146167
--title "chore: bump version to ${{ env.VERSION }}" \
147-
--body "Automated PR to update version after PyPI release." \
168+
--body "$PR_BODY" \
148169
--base main \
149-
--head "$BRANCH_NAME"
170+
--head "$BRANCH_NAME")
171+
172+
echo "PR created: $PR_URL"

0 commit comments

Comments
 (0)