Skip to content

automate version bumping #4

automate version bumping

automate version bumping #4

name: Publish Python Package
on:
push:
tags:
- 'v*' # Triggers on tags that start with 'v', e.g., 'v1.0.0'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry bump2version
- name: Update version in pyproject.toml based on tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
bump2version --new-version $TAG_NAME --allow-dirty --no-commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "Bump version to $TAG_NAME"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build the package
run: poetry build
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install twine
twine upload dist/* --skip-existing