Skip to content

Commit 57ec358

Browse files
committed
Add workflow_dispatch for version bump, release, and PyPI publish
Replace the release-triggered publish workflow with a manual workflow_dispatch that bumps the version (major/minor/patch), commits and tags the change, creates a GitHub release via gh CLI, and publishes to PyPI.
1 parent 6a8d667 commit 57ec358

File tree

1 file changed

+56
-9
lines changed

1 file changed

+56
-9
lines changed

.github/workflows/main.yml

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
name: Publish Python Package
1+
name: Bump Version and Publish
22

33
on:
4-
release:
5-
types:
6-
- published
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: "Version bump type"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
714

815
jobs:
9-
pypi-publish:
10-
name: upload release to PyPI
16+
bump-version-and-publish:
17+
name: Bump version, release, and publish to PyPI
1118
runs-on: ubuntu-latest
1219
permissions:
13-
contents: read
20+
contents: write
1421
id-token: write
1522
steps:
1623
- uses: actions/checkout@v4
1724
with:
18-
ref: ${{ github.event.release.tag_name }}
25+
fetch-depth: 0
1926

2027
- uses: actions/setup-python@v5
2128
with:
@@ -24,9 +31,49 @@ jobs:
2431
- name: Install uv
2532
uses: astral-sh/setup-uv@v5
2633
with:
27-
# Install a specific version of uv.
2834
version: "0.6.14"
2935

36+
- name: Bump version
37+
id: bump
38+
run: |
39+
CURRENT_VERSION=$(python -c "import re; content=open('src/unstract/llmwhisperer/__init__.py').read(); print(re.search(r'__version__\s*=\s*\"(.+?)\"', content).group(1))")
40+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
41+
42+
case "${{ github.event.inputs.version_type }}" in
43+
major)
44+
MAJOR=$((MAJOR + 1))
45+
MINOR=0
46+
PATCH=0
47+
;;
48+
minor)
49+
MINOR=$((MINOR + 1))
50+
PATCH=0
51+
;;
52+
patch)
53+
PATCH=$((PATCH + 1))
54+
;;
55+
esac
56+
57+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
58+
echo "old_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
59+
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
60+
61+
sed -i "s/__version__ = \"$CURRENT_VERSION\"/__version__ = \"$NEW_VERSION\"/" src/unstract/llmwhisperer/__init__.py
62+
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"
67+
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
71+
72+
- name: Create GitHub Release
73+
env:
74+
GH_TOKEN: ${{ github.token }}
75+
run: gh release create "v${{ steps.bump.outputs.new_version }}" --generate-notes
76+
3077
- name: Build package
3178
run: uv build
3279

0 commit comments

Comments
 (0)