Update FEZrs_PyPI_Publish.yml #90
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: PyPI Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
pypi_publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Needed for setuptools_scm to detect tags | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools setuptools_scm wheel twine build | |
- name: Determine version | |
run: | | |
VERSION=$(python setup.py --version) | |
echo "Current version: $VERSION" | |
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Bump version (if needed) | |
run: | | |
OLD_VERSION=${{ env.PACKAGE_VERSION }} | |
NEW_VERSION=$(echo $OLD_VERSION | awk -F. -v OFS=. '{$NF++;print}') | |
echo "New version: $NEW_VERSION" | |
# Create new tag and push it | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
git tag $NEW_VERSION | |
git push origin $NEW_VERSION | |
- name: Build PyPI package | |
run: python -m build | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: python -m twine upload dist/* |