This Github Action provides a consistent action for building and releasing Python command line tools on the St. Jude Cloud project. It may also be used generally, provided your package conforms the following set of prerequisites:
- Poetry is used for package management.
- Conventional commits are used to describe changes to the project.
This action will always complete the following tasks, though we may change how it achieves them in future releases.
- Automate releases to PyPI using conventional commits/semantic releases.
- Currently python-semantic-release is used to achieve this.
- Automate release to Github using conventional commits/semantic releases.
- Currently conventional-github-releaser is used to achieve this (we've)
found this to be better than using
python-semantic-release
for this purpose).
- Currently conventional-github-releaser is used to achieve this (we've)
found this to be better than using
The most basic implementation using this Github action can be achieved by
creating a release.yml
file within the .github/workflows
directory with the
following contents:
name: Release
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: stjudecloud/release-python-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
You'll need to complete a few more steps to ensure things work correctly:
- Add
python-semantic-release
to your dev dependencies (poetry add -D python-semantic-release
). - Ensure the branch above matches your default branch. If your default
branch is
main
, be sure to change it both in the Github Action and thepyproject.yml
entry fromtool.semantic_release
! - Make sure you add a
PYPI_TOKEN
secret to your repository so that the package can be published successfully. - Ensure you have a complete
pyproject.toml
file. You'll need to set the appropriate settings forpython-semantic-release
, which you can find documented here. We recommend using the following code snippet as a starting place.
[tool.semantic_release]
branch = "master"
build_command = "poetry build"
commit_author = "St. Jude Cloud <support@stjude.cloud>"
commit_message = ""
commit_subject = "chore: bumping version to v{version}"
upload_to_release = "false"
version_source = "commit"
version_variable = "pyproject.toml:version"
Please file an issue on this repository if you encounter any issues.