To execute cz bump in your CI, and push the new commit and
the new tag, back to your master branch, we have to:
- Create a personal access token. Follow the instructions here. And copy the generated key
- Create a secret called
PERSONAL_ACCESS_TOKEN, with the copied key, by going to your project repository and thenSettings > Secrets > Add new secret. - In your repository create a new file
.github/workflows/bumpversion.ymlwith the following content.
name: Bump version
on:
push:
branches:
- master
jobs:
bump-version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@v2
with:
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
fetch-depth: 0
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
Push to master and that's it.
Once the new tag is created, triggering an automatic publish command would be desired.
In order to do so, the crendetial needs to be added with the information of our PyPI account.
Instead of using username and password, we suggest using api token generated from PyPI.
After generate api token, use the token as the PyPI password and __token__ as the username.
Go to Settings > Secrets > Add new secret and add the secret: PYPI_PASSWORD.
Create a file in .github/workflows/pythonpublish.yaml with the following content:
name: Upload Python Package
on:
push:
tags:
- '*' # Will trigger for every tag, alternative: 'v*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --pre -U poetry
poetry --version
poetry install
- name: Build and publish
env:
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
./scripts/publishNotice that we are calling a bash script in ./scripts/publish, you should configure it with your tools (twine, poetry, etc.). Check commitizen example
You can also use pypa/gh-action-pypi-publish to publish your package.
Push the changes and that's it.