publish to pypi #45
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 to pypi | |
on: | |
workflow_run: | |
workflows: quality checks | |
branches: main | |
types: completed | |
jobs: | |
version-and-publish: | |
# `if` required because a workflow run is triggered regardless of | |
# the result of the previous workflow (see the documentation page) | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} && "!contains(github.event.head_commit.message, '[ci skip]')" | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: actions/checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
- name: bump_version | |
run: | | |
set -x | |
git config --global user.name jmfiola | |
git config --global user.email jmfiola21@gmail.com | |
git config --global pull.rebase false | |
BRANCH=${GITHUB_REF#refs/heads/} | |
pip install --no-cache-dir bump2version | |
git remote add jmfiola https://jmfiola:${{ secrets.PERSONAL_ACCESS_TOKEN}}@github.com/$GITHUB_REPOSITORY | |
git pull --no-edit jmfiola $BRANCH | |
# merge done by git pull does not update submodules changed in $BRANCH | |
bump2version patch --allow-dirty --tag --commit --commit-args="-a" | |
git push --tags jmfiola HEAD:$BRANCH | |
- name: Build package | |
run: | | |
pip install twine build | |
python -m build | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |