Update FEZrs_PyPI_Publish.yml #92
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 # Required for setuptools_scm to detect version | |
- 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) # Now setuptools_scm is installed | |
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" | |
# Update the VERSION file | |
echo "$NEW_VERSION" > VERSION | |
# Commit & push the new version | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
git add VERSION | |
git commit -m "Bump version to $NEW_VERSION" | |
git tag $NEW_VERSION | |
git push origin $NEW_VERSION | |
git push | |
- 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/* |