Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 56 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
name: Publish Python Package
name: Bump Version and Publish

on:
release:
types:
- published
workflow_dispatch:
inputs:
version_type:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major

jobs:
pypi-publish:
name: upload release to PyPI
bump-version-and-publish:
name: Bump version, release, and publish to PyPI
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
fetch-depth: 0

- uses: actions/setup-python@v5
with:
Expand All @@ -24,9 +31,49 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.6.14"

- name: Bump version
id: bump
run: |
CURRENT_VERSION=$(python -c "import re; content=open('src/unstract/llmwhisperer/__init__.py').read(); print(re.search(r'__version__\s*=\s*\"(.+?)\"', content).group(1))")
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"

case "${{ github.event.inputs.version_type }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac

NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "old_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"

sed -i "s/__version__ = \"$CURRENT_VERSION\"/__version__ = \"$NEW_VERSION\"/" src/unstract/llmwhisperer/__init__.py

- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/unstract/llmwhisperer/__init__.py
git commit -m "Bump version to v${{ steps.bump.outputs.new_version }}"
git tag "v${{ steps.bump.outputs.new_version }}"
git push origin main --tags

- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "v${{ steps.bump.outputs.new_version }}" --generate-notes

- name: Build package
run: uv build

Expand Down
Loading