Skip to content

Auto bump version to 1.22.7 #119

Auto bump version to 1.22.7

Auto bump version to 1.22.7 #119

# workflow automates the Python package publishing process
# to PyPI upon pushes to the main branch or manual triggers,
# auto-bumps version before publishing.
name: Publish to PyPI
on:
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
- name: Get current version
run: |
current_version=$(grep 'version =' pyproject.toml | cut -d'"' -f2)
echo "CURRENT_VERSION=$current_version" >> $GITHUB_ENV
- name: Bump version
run: |
IFS=. read -r major minor patch <<< "${CURRENT_VERSION}"
patch=$((patch + 1))
new_version="${major}.${minor}.${patch}"
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
- name: Update version in setup.py
run: |
sed -i "s/version='.*'/version='$NEW_VERSION'/" setup.py
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
- name: Commit version bump
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Auto bump version to $NEW_VERSION"
git push origin main
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Re-run poetry lockfile
run: poetry lock
- name: Install project dependencies
run: poetry install
- name: Build package
run: poetry build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}