Skip to content

Use pypa/gh-action-pypi-publish@master #4

Use pypa/gh-action-pypi-publish@master

Use pypa/gh-action-pypi-publish@master #4

name: Publish Python Package
on:
push:
branches:
- main
permissions:
contents: write # Needed to push changes back to the repository
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for tags and branches
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bump2version
- name: Bump version
id: bump_version
run: |
VERSION=$(bump2version patch --allow-dirty --list | grep new_version= | cut -d'=' -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
shell: bash
- name: Commit version bump
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Version bump to ${{ env.VERSION }} [skip ci]'
file_pattern: |
setup.py
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ env.VERSION }}"
name: "v${{ env.VERSION }}"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install build tool
run: pip install build
- name: Build package
run: python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}