11name : Publish to PyPI
22
33on :
4+ push :
5+ branches : [dickson/version-bump] # TESTING ONLY - REMOVE BEFORE MERGE
46 workflow_dispatch :
57 inputs :
68 version :
79 description : ' Version to publish (e.g., 0.1.0)'
810 required : true
911 type : string
10- test_pypi :
11- description : ' Publish to Test PyPI first'
12- required : false
13- type : boolean
14- default : true
15-
12+ default : ' 0.0.15' # TESTING ONLY - REMOVE BEFORE MERGE
1613jobs :
1714 test :
1815 runs-on : ubuntu-latest
@@ -79,11 +76,16 @@ jobs:
7976 with :
8077 python-version : ' 3.12'
8178
79+ - name : Set version
80+ id : version
81+ run : |
82+ VERSION="${{ github.event.inputs.version || '0.0.15' }}" # TESTING ONLY - defaults to 0.0.15
83+ echo "VERSION=$VERSION" >> $GITHUB_ENV
84+ echo "version=$VERSION" >> $GITHUB_OUTPUT
85+
8286 - name : Update version
8387 run : |
84- # Update version in pyproject.toml
85- sed -i 's/version = ".*"/version = "${{ github.event.inputs.version }}"/' pyproject.toml
86- sed -i 's/__version__ = ".*"/__version__ = "${{ github.event.inputs.version }}"/' src/claude_code_sdk/__init__.py
88+ python scripts/update_version.py "${{ env.VERSION }}"
8789
8890 - name : Install build dependencies
8991 run : |
@@ -96,31 +98,21 @@ jobs:
9698 - name : Check package
9799 run : twine check dist/*
98100
99- - name : Publish to Test PyPI
100- if : ${{ github.event.inputs.test_pypi == 'true' }}
101- env :
102- TWINE_USERNAME : __token__
103- TWINE_PASSWORD : ${{ secrets.TEST_PYPI_API_TOKEN }}
104- run : |
105- twine upload --repository testpypi dist/*
106- echo "Package published to Test PyPI"
107- echo "Install with: pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ claude-code-sdk==${{ github.event.inputs.version }}"
108-
109101 - name : Publish to PyPI
110102 env :
111103 TWINE_USERNAME : __token__
112104 TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
113105 run : |
114106 twine upload dist/*
115107 echo "Package published to PyPI"
116- echo "Install with: pip install claude-code-sdk==${{ github.event.inputs.version }}"
108+ echo "Install with: pip install claude-code-sdk==${{ env.VERSION }}"
117109
118110 - name : Create version update PR
119111 env :
120112 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
121113 run : |
122114 # Create a new branch for the version update
123- BRANCH_NAME="release/v${{ github.event.inputs.version }}"
115+ BRANCH_NAME="release/v${{ env.VERSION }}"
124116 git checkout -b "$BRANCH_NAME"
125117
126118 # Configure git
@@ -129,25 +121,29 @@ jobs:
129121
130122 # Commit the version changes
131123 git add pyproject.toml src/claude_code_sdk/__init__.py
132- git commit -m "chore: bump version to ${{ github.event.inputs.version }}"
124+ git commit -m "chore: bump version to ${{ env.VERSION }}
125+
126+ This PR updates the version to ${{ env.VERSION }} after publishing to PyPI.
127+
128+ ## Changes
129+ - Updated version in \`pyproject.toml\`
130+ - Updated version in \`src/claude_code_sdk/__init__.py\`
131+
132+ ## Release Information
133+ - Published to PyPI: https://pypi.org/project/claude-code-sdk/${{ env.VERSION }}/
134+ - Install with: \`pip install claude-code-sdk==${{ env.VERSION }}\`
135+
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>"
133140
134141 # Push the branch
135142 git push origin "$BRANCH_NAME"
136143
137144 # Create PR using GitHub CLI (gh)
138145 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." \
146+ --title "chore: bump version to ${{ env.VERSION }}" \
147+ --body "Automated PR to update version after PyPI release." \
152148 --base main \
153149 --head "$BRANCH_NAME"
0 commit comments