-
Notifications
You must be signed in to change notification settings - Fork 7
81 lines (69 loc) · 2.31 KB
/
main.yml
File metadata and controls
81 lines (69 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Bump Version and Publish
on:
workflow_dispatch:
inputs:
version_type:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
jobs:
bump-version-and-publish:
name: Bump version, release, and publish to PyPI
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12.9"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
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
- name: Publish to PyPI
run: uv publish