38
pypi packages with GitHub actions
GitHub actions are a great way to get your ci/cd done.
In this post we will see how we can run ci flow with lint, package, test and publish a python package. Using the sample repo
https://github.com/uptownaravi/encoder
This will help you get started on a simple GitHub action for a pypi package.
Refer to GitHub Workflow Syntax for documentation.
Workflows have jobs and steps under that, our workflow is defined in the file
https://github.com/uptownaravi/encoder/blob/main/.github/workflows/pythonaction.yml
This is configured to run when a commit happens on the main branch.
The steps in the workflow include
Version is read from the version file both on the setup.py and in the workflow during install/test
Once we make a commit on the main branch, we can see the workflow run on the actions tab of the repository

| Note: if you notice the workflow file we can see a secret being used with in package upload. Add a GitHub secret called PYPI_TOKEN which has the token from pypi account.
| Check https://pypi.org/help/#apitoken for steps to generate the token
38