MNT version 0.0.5 #2
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 | |
# Deploy to PyPI if the __version__ variable in moten/__init__.py | |
# is larger than the latest version on PyPI. | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
# trigger workflow only on commits that change __init__.py | |
- 'moten/__init__.py' | |
jobs: | |
deploy-pypi: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- name: Get versions | |
# Compare the latest version on PyPI, and the current version | |
run: | | |
python -m pip install --upgrade -q pip | |
pip index versions pymoten | |
LATEST=$(pip index versions pymoten | grep 'pymoten' |awk '{print $2}' | tr -d '(' | tr -d ')') | |
CURRENT=$(cat moten/__init__.py | grep "__version__" | awk '{print $3}' | tr -d "'" | tr -d '"') | |
EQUAL=$([ "$CURRENT" = "$LATEST" ] && echo 1 || echo 0) | |
echo "LATEST=$LATEST" >> $GITHUB_ENV | |
echo "CURRENT=$CURRENT" >> $GITHUB_ENV | |
echo "EQUAL=$EQUAL" >> $GITHUB_ENV | |
- name: Print versions | |
run: | | |
echo ${{ env.LATEST }} | |
echo ${{ env.CURRENT }} | |
echo ${{ env.EQUAL }} | |
- name: Build and publish | |
if: ${{ env.EQUAL == 0 }} | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install setuptools wheel twine | |
python setup.py sdist bdist_wheel | |
python -m twine upload dist/* |