1- name : Bump Version and Publish
1+ name : Release Tag and Publish Package
22
33on :
44 workflow_dispatch :
55 inputs :
6- version_type :
6+ version_bump :
77 description : " Version bump type"
88 required : true
9+ default : " patch"
910 type : choice
1011 options :
1112 - patch
1213 - minor
1314 - major
15+ pre_release :
16+ description : " Create as pre-release"
17+ required : false
18+ default : false
19+ type : boolean
20+
21+ permissions :
22+ id-token : write
23+ contents : read
1424
1525jobs :
16- bump-version-and-publish :
17- name : Bump version, release, and publish to PyPI
26+ release-and-publish :
1827 runs-on : ubuntu-latest
28+ environment : release
1929 permissions :
2030 contents : write
2131 id-token : write
2232 steps :
33+ - name : Generate GitHub App Token
34+ id : generate-token
35+ uses : actions/create-github-app-token@v2
36+ with :
37+ app-id : ${{ vars.PUSH_TO_MAIN_APP_ID }}
38+ private-key : ${{ secrets.PUSH_TO_MAIN_APP_PRIVATE_KEY }}
39+ owner : Zipstack
40+ repositories : |
41+ llm-whisperer-python-client
42+
2343 - uses : actions/checkout@v4
2444 with :
45+ token : ${{ steps.generate-token.outputs.token }}
2546 fetch-depth : 0
2647
48+ - name : Configure Git
49+ run : |
50+ git config --global user.name "github-actions[bot]"
51+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
52+
2753 - uses : actions/setup-python@v5
2854 with :
2955 python-version : " 3.12.9"
@@ -33,13 +59,15 @@ jobs:
3359 with :
3460 version : " 0.6.14"
3561
36- - name : Bump version
37- id : bump
62+ - name : Bump version and create release
63+ id : create_release
3864 run : |
3965 CURRENT_VERSION=$(python -c "import re; content=open('src/unstract/llmwhisperer/__init__.py').read(); print(re.search(r'__version__\s*=\s*\"(.+?)\"', content).group(1))")
66+ echo "Current version: $CURRENT_VERSION"
67+
4068 IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
4169
42- case "${{ github.event.inputs.version_type }}" in
70+ case "${{ github.event.inputs.version_bump }}" in
4371 major)
4472 MAJOR=$((MAJOR + 1))
4573 MINOR=0
@@ -55,27 +83,44 @@ jobs:
5583 esac
5684
5785 NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
58- echo "old_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT "
59- echo "new_version =$NEW_VERSION" >> " $GITHUB_OUTPUT"
86+ echo "New version: $NEW_VERSION "
87+ echo "version =$NEW_VERSION" >> $GITHUB_OUTPUT
6088
6189 sed -i "s/__version__ = \"$CURRENT_VERSION\"/__version__ = \"$NEW_VERSION\"/" src/unstract/llmwhisperer/__init__.py
6290
63- - name : Commit and tag
64- run : |
65- git config user.name "github-actions[bot]"
66- git config user.email "github-actions[bot]@users.noreply.github.com"
6791 git add src/unstract/llmwhisperer/__init__.py
68- git commit -m "Bump version to v${{ steps.bump.outputs.new_version }}"
69- git tag "v${{ steps.bump.outputs.new_version }}"
70- git push origin main --tags
92+ git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
93+ git push origin main
94+ git tag "v$NEW_VERSION"
95+ git push origin "v$NEW_VERSION"
96+
97+ gh release create "v$NEW_VERSION" \
98+ --title "Release v$NEW_VERSION" \
99+ --generate-notes \
100+ ${{ github.event.inputs.pre_release == 'true' && '--prerelease' || '' }}
71101
72- - name : Create GitHub Release
102+ echo "Created release v$NEW_VERSION"
73103 env :
74- GH_TOKEN : ${{ github.token }}
75- run : gh release create "v${{ steps.bump.outputs.new_version }}" --generate-notes
104+ GITHUB_TOKEN : ${{ steps.generate-token.outputs.token }}
105+
106+ - name : Verify version update
107+ run : |
108+ FILE_VERSION=$(python -c "import re; content=open('src/unstract/llmwhisperer/__init__.py').read(); print(re.search(r'__version__\s*=\s*\"(.+?)\"', content).group(1))")
109+ echo "File version: $FILE_VERSION"
110+ echo "Target version: ${{ steps.create_release.outputs.version }}"
111+ if [ "$FILE_VERSION" != "${{ steps.create_release.outputs.version }}" ]; then
112+ echo "Version mismatch! Exiting..."
113+ exit 1
114+ fi
76115
77116 - name : Build package
78117 run : uv build
79118
80119 - name : Publish to PyPI
81120 run : uv publish
121+
122+ - name : Success message
123+ run : |
124+ echo "Successfully published version ${{ steps.create_release.outputs.version }} to PyPI"
125+ echo "Release: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.create_release.outputs.version }}"
126+ echo "PyPI: https://pypi.org/project/llmwhisperer-client/${{ steps.create_release.outputs.version }}/"
0 commit comments