Skip to content

Merge pull request #11 from awhipp/bugfix/add_proper_gh_credentials #6

Merge pull request #11 from awhipp/bugfix/add_proper_gh_credentials

Merge pull request #11 from awhipp/bugfix/add_proper_gh_credentials #6

Workflow file for this run

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
env:
GH_USER_EMAIL: ${{ secrets.GH_USER_EMAIL }}
GH_USER_NAME: ${{ secrets.GH_USER_NAME }}
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
git add pyproject.toml
git config --global user.email "$GH_USER_EMAIL"
git config --global user.name "$GH_USER_NAME"
git commit -m "chore: Bump version ($version_bump)"
git push origin main