Skip to content
name: Publish Python 🐍 distributions πŸ“¦ to PyPI
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'deploy')"
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: |
pip install bumpversion setuptools wheel twine
- name: Generate Git Tag
id: generate_tag
run: |

Check failure on line 27 in .github/workflows/publish-to-pypi.yml

View workflow run for this annotation

GitHub Actions / Publish Python 🐍 distributions πŸ“¦ to PyPI

Invalid workflow file

The workflow is not valid. .github/workflows/publish-to-pypi.yml (Line: 27, Col: 12): Unexpected symbol: '$PYPI_TAG'. Located at position 1 within expression: $PYPI_TAG
VERSION_PREFIX="v"
VERSION_MAJOR_MINOR="1.0"
VERSION_PATCH=$(git tag --list "${VERSION_PREFIX}${VERSION_MAJOR_MINOR}.*" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+$')
if [ -z "$VERSION_PATCH" ]; then
VERSION_PATCH=0
else
VERSION_PATCH=$((VERSION_PATCH + 1))
fi
PYPI_TAG="${VERSION_MAJOR_MINOR}.${VERSION_PATCH}"
NEW_TAG="${VERSION_PREFIX}${PYPI_TAG}"
echo "Generated new tag: $NEW_TAG"
echo "Generated new PYPI tag: $PYPI_TAG"
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
echo "PYPI_TAG=$PYPI_TAG" >> $GITHUB_ENV
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ $PYPI_TAG }}/g" setup.py
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Push Git Tag
run: |
git config user.name "GitHub Actions"
git config user.email "github-actions@users.noreply.github.com"
git tag $NEW_TAG
git push origin $NEW_TAG