RELEASING.rst
Overview
This document outlines the official procedure and policies for releasing new versions of the `pytest` software project. It provides detailed instructions for both automated and manual release workflows, covering bug-fix, minor, major, and release candidate versions. The purpose of this file is to ensure consistent, reliable, and efficient release processes that balance timely delivery of fixes and features with quality control.
Key functionalities include:
Defining the release cadence and types (bug-fix, minor, major, release candidate).
Explaining the automated GitHub Actions workflow for preparing releases.
Outlining manual steps for preparing and releasing versions.
Detailing post-approval steps such as deployment, tagging, cherry-picking changelogs, and announcements.
Specifying Git branching and remote repository setup conventions.
This file serves as the authoritative guide for maintainers and contributors involved in the release process.
Detailed Explanation of Sections
1. Release Policy and Branch Setup
Release Frequency: Bug-fix releases occur every few weeks; minor releases every 2-3 months.
Git Remotes Assumed:
origin: Your personal fork of the repository.upstream: The officialpytest-dev/pytestrepository.
This ensures that contributors correctly push branches and interact with the official repo.
2. Preparing: Automatic Method
This section describes the GitHub Actions-based automation for preparing release pull requests (PRs).
Workflow Trigger: Manually triggered GitHub workflow
prepare-release-pr.yml.Version Number Determination Logic:
If
major releaseinput is "yes", increment major version (e.g., 7.0.0 → 8.0.0).If
.feature.rstor.breaking.rstfiles exist in the changelog directory, increment minor version.Otherwise, increment patch (bug-fix) version.
If
prereleaseinput is set (e.g.,rc1), append to version number (e.g.,8.0.0rc1).
Usage Examples:
Trigger minor release PR on maintenance branch
7.1.x:gh workflow run prepare-release-pr.yml -f branch=7.1.x -f major=no -f prerelease=Trigger major release PR on maintenance branch
8.0.x:gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=Trigger a release candidate PR for
8.0.0rc1:gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=rc1Branching Notes:
Minor and bug-fix releases are done from maintenance branches like
7.1.xor7.0.x.Major releases require creating a new maintenance branch from
main.
3. Preparing: Manual Method
If automation is not used, releases can be prepared manually (Linux environment required).
**Steps:**
Create and push maintenance branch for major/minor releases:
git fetch upstream git branch MAJOR.MINOR.x upstream/main git push upstream MAJOR.MINOR.xCreate a release branch from the maintenance branch:
git checkout -b release-MAJOR.MINOR.PATCH MAJOR.MINOR.xGenerate documentation, changelog, and announcements using
tox:tox -e release -- MAJOR.MINOR.PATCHPush changes and open a PR targeting the maintenance branch.
4. Releasing (Post-PR Approval)
Once the PR is approved and tests pass:
Trigger the deployment workflow on GitHub Actions (
deploy.yml) using the release branch.CLI example:
gh workflow run deploy.yml -R pytest-dev/pytest --ref=release-MAJOR.MINOR.PATCH -f version=MAJOR.MINOR.PATCHThe
deployjob publishes the release to PyPI and tags the repository. Approval bypytest-dev/coreis required.Merge the release PR without squash merging to preserve the tagged commit in
main.Cherry-pick changelog and announcement commits to
main:git fetch upstream git checkout upstream/main -b cherry-pick-release git cherry-pick -x -m1 upstream/MAJOR.MINOR.xOpen and merge a PR for
cherry-pick-releaseafter CI passes.For major and minor releases (or first prerelease), tag a dev version on
mainfor the next feature cycle:git checkout main git pull git tag MAJOR.{MINOR+1}.0.dev0 git push upstream MAJOR.{MINOR+1}.0.dev0Send an email announcement using the contents from
doc/en/announce/release-<VERSION>.rstto Python mailing lists and social media.
Important Implementation Details
The automated workflow leverages GitHub Actions to reduce manual errors and speed up release preparations.
It uses the presence of specific changelog files (
.feature.rst,.breaking.rst) to decide version increments, aligning with semantic versioning principles.Release branches follow a strict naming convention (
release-MAJOR.MINOR.PATCH) and are created from maintenance branches.Cherry-picking changelog commits back to
mainkeeps the main branch up to date with release notes.The process prohibits squash merges for release PRs to ensure the tagged commit remains in
main.Releases must be prepared on Linux to ensure documentation and examples execute correctly.
Interaction with Other Parts of the System
GitHub Actions Workflows:
prepare-release-pr.yml: Automates PR creation for new releases.deploy.yml: Handles deployment to PyPI and repository tagging.
Repository Structure:
Uses
mainas the primary development branch.Maintenance branches (
MAJOR.MINOR.x) isolate release series.originandupstreamremotes coordinate personal forks and official repo updates.
Changelog and Announcements:
Stored in
changelogdirectory anddoc/en/announce/.Used by release automation to generate version bumps and announcements.
Tooling:
toxenvironmentreleaseautomates changelog, docs, and announcement generation.
Usage Examples Summary
Triggering an automated minor release PR:
gh workflow run prepare-release-pr.yml -f branch=7.1.x -f major=no -f prerelease=Preparing a manual release branch:
git fetch upstream git branch 7.1.x upstream/main git push upstream 7.1.x git checkout -b release-7.1.0 7.1.x tox -e release -- 7.1.0Deploying a release:
gh workflow run deploy.yml -R pytest-dev/pytest --ref=release-7.1.0 -f version=7.1.0
Visual Diagram
The following flowchart depicts the automated release preparation workflow and subsequent release steps, highlighting key decision points and interactions:
flowchart TD
A[Trigger prepare-release-pr.yml workflow] --> B{Is 'major release' input 'yes'?}
B -- Yes --> C[Increment major version]
B -- No --> D{Any .feature.rst or .breaking.rst files?}
D -- Yes --> E[Increment minor version]
D -- No --> F[Increment patch version]
C --> G{Is 'prerelease' input set?}
E --> G
F --> G
G -- Yes --> H[Append prerelease suffix to version]
G -- No --> I[Use version as is]
H --> J[Create PR branch release-MAJOR.MINOR.PATCH]
I --> J
J --> K[Open PR for release branch]
K --> L{PR approved and tests pass?}
L -- Yes --> M[Trigger deploy.yml workflow]
M --> N[Publish to PyPI & tag repo]
N --> O[Merge PR without squash]
O --> P[Cherry-pick changelog to main]
P --> Q[Tag dev version for next release]
Q --> R[Send release announcements]
This diagram clarifies the automated decision logic for version increments and illustrates the release pipeline from PR creation to announcement.
This comprehensive document ensures all maintainers and contributors understand the release workflow, adhere to best practices, and maintain release quality and consistency.