MNT version 0.2.1 #8
This file contains hidden or 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 voxelwise_tutorials/__init__.py | |
# is larger than the latest version on PyPI. | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
# trigger workflow only on commits that change __init__.py | |
- 'voxelwise_tutorials/__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 voxelwise_tutorials | |
LATEST=$(pip index versions voxelwise_tutorials | grep 'voxelwise_tutorials' |awk '{print $2}' | tr -d '(' | tr -d ')') | |
CURRENT=$(cat voxelwise_tutorials/__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: Install pypa/build | |
run: >- | |
python -m | |
pip install | |
build | |
- name: Build a source tarball | |
run: >- | |
python -m | |
build | |
--sdist | |
--outdir dist/ | |
- name: Publish | |
if: ${{ env.EQUAL == 0 }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_PASSWORD }} |