Start from a clean checkout at main.
Before running through the release it's good to run the build and the tests locally, and make sure CI is passing. You can also test-drive the commit in an existing Bazel workspace to sanity check functionality.
Releases are managed using a semi-automated process centered around a GitHub Release Tracking Issue and automated workflows triggered by comments or issue edits.
Note
Comment-based commands must be posted by project maintainers (Owner, Member, or Collaborator) and must be on their own line (leading and trailing whitespace is ignored).
-
Prepare the Release: Run the Release: Prepare workflow manually. You can trigger it from the GitHub Actions UI or using the GitHub CLI:
gh workflow run release_prepare.yaml --repo bazel-contrib/rules_python
This will automatically determine the next version, create a release tracking issue, and send a preparation PR.
-
Approve and Merge: Approve and merge the PR. Once merged, a release branch will be created automatically.
-
Add Backports (if needed): If there are backports, add them following the How to add backports steps.
-
Create an RC: Comment
/create-rcon the tracking issue. This will automatically process pending backports before creating the RC. If any backport fails, the RC creation will abort. -
Iterate: Repeat steps 3 and 4 until backports and RCs are no longer needed.
-
Finalize the Release: Comment
/promoteon the tracking issue to finalize the release.
The release workflow can be manually triggered using the GitHub CLI (gh).
This is useful for re-running a release or for creating a release from a
specific commit.
To trigger the workflow, use the gh workflow run command:
gh workflow run release_publish.yaml --ref <TAG>By default, the workflow will publish the wheel to PyPI. To skip this step,
you can set the publish_to_pypi input to false:
gh workflow run release_publish.yaml --ref <TAG> -f publish_to_pypi=falserules_python uses semantic version, so releases with API changes and new features bump the minor, and those with only bug fixes and other minor changes bump the patch digit.
The release tool will automatically determine the next version number based on
the VERSION_NEXT_* placeholders in the codebase. To see what changes are
being accumulated for the next release, review the pending news entries in the
news/ directory.
To add backports to an active release, you can use one of the following methods:
- Manually add checklist items under the
## Backportssection of the Release Tracking Issue. The format must be:- [ ] #<PR_NUMBER>(e.g.,- [ ] #1234). - When ready, comment
/process-backportson the tracking issue to trigger processing.
- Comment
/add-backports <PR_NUMBER> [<PR_NUMBER> ...](space or comma separated) on the tracking issue. This will automatically add the PRs to the checklist and trigger processing.
If a backport fails to process (e.g., due to cherry-pick conflicts):
- The failed backport checklist item will remain unchecked with
status=error-<reason>. - You must resolve the conflict manually: checkout the release branch,
cherry-pick the PR, resolve conflicts, push to remote, and manually check
the box on the tracking issue checklist with
status=donemetadata.
If a patch release from head would contain changes that aren't appropriate for a patch release, then the patch release needs to be based on the original release tag and the patch changes cherry-picked into it.
In this example, release 0.37.0 is being patched to create release 0.37.1.
The fix being included is commit deadbeef.
git checkout release/0.37git cherry-pick -x deadbeef- Fix merge conflicts, if any.
git cherry-pick --continue(if applicable)git push upstream
If multiple commits need to be applied, repeat the git cherry-pick step for
each.
Once the release branch is in the desired state, comment /create-rc on the
tracking issue to tag it, as done with a release from head.
We announce releases in the #python channel in the Bazel slack (bazelbuild.slack.com). Here's a template:
Greetings Pythonistas,
rules_python X.Y.Z-rcN is now available
Changelog: https://rules-python.readthedocs.io/en/X.Y.Z-rcN/changelog.html#vX-Y-Z
It will be promoted to stable next week, pending feedback.
It's traditional to include notable changes from the changelog, but not required.
Re-releasing a version (i.e. changing the commit a tag points to) is sometimes possible, but it depends on how far into the release process it got.
The two points of no return are:
- If the PyPI package has been published: PyPI disallows using the same filename/version twice. Once published, it cannot be replaced.
- If the BCR package has been published: Once it's been committed to the BCR registry, it cannot be replaced.
If release steps fail prior to those steps, then its OK to change the tag. You may need to manually delete the GitHub release.
You can manually edit the Release Tracking Issue to control the release flow.
The checklist items use metadata suffix: | key=value key2=value2.
- Retry Prepare Release: Reset the task to
- [ ] Prepare Release | status=awaiting-preparation. - Force Task Done: Check the box
- [x]and add appropriate metadata (e.g.status=done).
Part of the release process uploads packages to PyPI as the user rules-python.
This account is managed by Google; contact rules-python-pyi@google.com if
something needs to be done with the PyPI account.