Skip to content

Chapter 7: Automating work through continuous integration

Continuous integration with GitHub Actions

  • Use the trigger event workflow_dispatch to enable manual execution of the workflow in the GitHub WebUI.
  • Use the trigger event push:on:branches:master to trigger an event after merging a pull request.
  • Use the jobs.<job_id>.strategy.matrix section to define special variables to which your workflow will instantiated and executed for each specified value.
  • Use cibuildwheel to create your wheels across different systems.
  • To call a reusable workflow, use jobs.<job_id>.uses.
Important

jobs.<job_id>.steps.uses is used for calling actions.

  • To call multiple workflows, you need to create one job for each.

Publishing on PyPi

  • By the time I did this exercise, the creation of new accounts in PyPi was suspended.
  • I created one in the test instance of PyPi: test.pypi.org
  • It seems that it is not possible anymore to upload packages by using the credentials to PyPi. Instead, you should activate two-factor authentication and then generate a token. Then, you should configure a file .pypirc similar to the following
[distutils]
index-servers = 
    testpypi

[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = <MY_TOKEN> 
  • Finally, you can use the twine command below to upload your package:
twine upload --verbose --config-file .pypirc -r testpypi dist/*
  • Next, you can access the uploaded project in the PyPI web interface and create a special token for the project. You are going to use this token to setup the publish package workflow using the action gh-action-pypi-publish

  • BumpVer is a tool that you can configure in the pyproject.toml file and that will help you update the version number of your package in all the files it appears.