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 π 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
|
||
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 |