ci: enable auto versioning #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Python Package to PyPI | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install Poetry and dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
- name: Configure Git user | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
- name: Update version for PyPI release | |
run: | | |
poetry version patch # Increment patch version (e.g., 0.1.0 -> 0.1.1) | |
git commit -am "Bump version to $(poetry version -s)" | |
git tag "v$(poetry version -s)" | |
git push origin --tags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build package | |
run: poetry build | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
poetry publish --build |