Bump version number #24
Workflow file for this run
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: Deploy to PyPI | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
deploy: | |
name: Publish 🐍 📦 to PyPI | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: release # the production branch name (for proper version #) | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Set env variables | |
run: | | |
chmod +x .github/workflows/utils.sh | |
source .github/workflows/utils.sh | |
VERSION_FILE=openpnm/__version__.py | |
echo "TAG=$(get_most_recent_tag)" >> $GITHUB_ENV | |
echo "VERSION=$(get_version $VERSION_FILE)" >> $GITHUB_ENV | |
- name: Set env variables (for tag mismatch) | |
run: | | |
echo "Tag: $TAG, Version: $VERSION" | |
if [ "${TAG//v}" = "${VERSION%.dev?}" ]; then | |
echo "TAG_MISMATCH=false" >> $GITHUB_ENV | |
else | |
echo "TAG_MISMATCH=true" >> $GITHUB_ENV | |
fi | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
echo "${{ github.event.ref }}" | |
echo "Tag/version mismatch: $TAG_MISMATCH" | |
- name: Build distribution 📦 | |
run: python setup.py sdist bdist_wheel | |
- name: Publish distribution 📦 to PyPI | |
if: startsWith(github.event.ref, 'refs/tags') && contains(env.TAG_MISMATCH, 'false') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} | |
skip-existing: true | |
# - name: Publish distribution 📦 to TestPyPI | |
# if: startsWith(github.event.ref, 'refs/tags') && contains(env.TAG_MISMATCH, 'false') | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# user: __token__ | |
# password: ${{ secrets.TESTPYPI_TOKEN }} | |
# repository_url: https://test.pypi.org/legacy/ | |
# Not a good idea: if a non-conforming tag is push, e.g. random_tag, it | |
# first gets deleted by cleanup-tags.yml, and then publish-to-pypi.yml gets | |
# tricked and deletes the most recent tag! Ouch! | |
# - name: Delete tag if doesn't match with version | |
# if: contains(env.TAG_MISMATCH, 'true') | |
# run: | | |
# git config --local user.email "[email protected]" | |
# git config --local user.name "GitHub Action" | |
# REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY} | |
# remote_repo="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${REPOSITORY}.git" | |
# git push "${remote_repo}" :refs/tags/$TAG |