-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 2 KB
/
bump_version.yml
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
name: Versioning Workflow
on:
push:
branches:
- main
jobs:
determine-version:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install and Configure Poetry & Git Credentials
run: |
python -m pip install poetry==1.8.2
python -m poetry config virtualenvs.in-project true
- name: Cache the virtualenv
uses: actions/cache@v4
with:
path: ./.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: python -m poetry install
- name: Analyze Commit Messages and Bump Version
run: |
# Custom script to analyze commit messages and determine version bump
## Stored in .github/analyze_git_history.py
## Assuming the script outputs the determined version bump as 'patch', 'minor', or 'major'
## Only None if there is no relevant commits.
version_bump=$(python .github/analyze_git_history.py)
if [ "$version_bump" == "patch" ]; then
poetry version patch
elif [ "$version_bump" == "minor" ]; then
poetry version minor
elif [ "$version_bump" == "major" ]; then
poetry version major
else
echo "Invalid version bump type ($version_bump). Skipping."
exit 0
fi
# Commit the version change to pyproject.toml
git add pyproject.toml
git config --global user.email "[email protected]"
git config --global user.name "Github Action Runner"
git commit -m "chore: Bump version ($version_bump)"
git push origin main
# Tag the commit with the new version
git tag $(poetry version -s)
git push origin $(poetry version -s)