release: Add convenience script for branch cutting

Adds a convenience script to do branch cut to simplify the amount of
commands run in order to do the physical action of cutting the branch.

Also updates documentation related to branch cutting

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/72219
Approved by: https://github.com/malfet, https://github.com/atalman
This commit is contained in:
Eli Uriegas
2022-03-15 22:23:53 +00:00
committed by PyTorch MergeBot
parent 6b92abe00f
commit ddb34e7b6a
2 changed files with 70 additions and 9 deletions

View File

@ -4,6 +4,8 @@
- [General Overview](#general-overview)
- [Cutting release branches](#cutting-release-branches)
- [`pytorch/pytorch`](#pytorchpytorch)
- [`pytorch/builder` / PyTorch domain libraries](#pytorchbuilder--pytorch-domain-libraries)
- [Making release branch specific changes](#making-release-branch-specific-changes)
- [Getting CI signal on release branches:](#getting-ci-signal-on-release-branches)
- [Drafting RCs (Release Candidates)](#drafting-rcs-release-candidates)
@ -31,26 +33,35 @@ Releasing a new version of PyTorch generally entails 3 major steps:
## Cutting release branches
### `pytorch/pytorch`
Release branches are typically cut from the branch [`viable/strict`](https://github.com/pytorch/pytorch/tree/viable/strict) as to ensure that tests are passing on the release branch.
Release branches *should* be prefixed like so:
```
release/{MAJOR}.{MINOR}
There's a convenience script to create release branches from current `viable/strict` (from root `pytorch/pytorch`):
```bash
DRY_RUN=disabled scripts/release/cut-release-branch.sh
```
An example of this would look like:
```
release/1.8
This script should create 2 branches:
* `release/{MAJOR}.{MINOR}`
* `orig/release/{MAJOR}.{MINOR}`
### `pytorch/builder` / PyTorch domain libraries
Convenience script can also be used domains as well as `pytorch/builder`
> NOTE: RELEASE_VERSION only needs to be specified if version.txt is not available in root directory
```bash
DRY_RUN=disabled GIT_BRANCH_TO_CUT_FROM=main RELEASE_VERSION=1.11 scripts/release/cut-release-branch.sh
```
Please make sure to create branch that pins divergent point of release branch from the main branch, i.e. `orig/release/{MAJOR}.{MINOR}`
### Making release branch specific changes
These are examples of changes that should be made to release branches so that CI / tooling can function normally on
them:
* Update target determinator to use release branch:
* Example: https://github.com/pytorch/pytorch/pull/40712
* Update backwards compatibility tests to use RC binaries instead of nightlies
* Example: https://github.com/pytorch/pytorch/pull/40706
* A release branches should also be created in [`pytorch/xla`](https://github.com/pytorch/xla) and [`pytorch/builder`](https://github.com/pytorch/builder) repos and pinned in `pytorch/pytorch`
@ -63,6 +74,7 @@ These are examples of changes that should be made to the *default* branch after
* Example: https://github.com/pytorch/pytorch/pull/65435
### Getting CI signal on release branches:
Create a PR from `release/{MAJOR}.{MINOR}` to `orig/release/{MAJOR}.{MINOR}` in order to start CI testing for cherry-picks into release branch.
Example:

View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
: '
So you are looking to cut a release branch? Well you came
to the right script.
This script can be used to cut any branch on any repository
For `pytorch/pytorch` usage would be like:
> DRY_RUN=disabled cut-release-branch.sh
For `pytorch/builder` or domains usage would be like:
> DRY_RUN=disabled GIT_BRANCH_TO_CUT_FROM=main RELEASE_VERSION=1.11 cut-release-branch.sh
'
set -eou pipefail
GIT_TOP_DIR=$(git rev-parse --show-toplevel)
GIT_REMOTE=${GIT_REMOTE:-origin}
GIT_BRANCH_TO_CUT_FROM=${GIT_BRANCH_TO_CUT_FROM:-viable/strict}
# should output something like 1.11
RELEASE_VERSION=${RELEASE_VERSION:-$(cut -d'.' -f1-2 "${GIT_TOP_DIR}/version.txt")}
DRY_RUN_FLAG="--dry-run"
if [[ ${DRY_RUN:-enabled} == "disabled" ]]; then
DRY_RUN_FLAG=""
fi
(
set -x
git fetch --all
git checkout "${GIT_REMOTE}/${GIT_BRANCH_TO_CUT_FROM}"
)
for branch in "release/${RELEASE_VERSION}" "orig/release/${RELEASE_VERSION}"; do
if git rev-parse --verify "${branch}" >/dev/null 2>/dev/null; then
echo "+ Branch ${branch} already exists, skipping..."
continue
else
(
set -x
git checkout "${GIT_REMOTE}/${GIT_BRANCH_TO_CUT_FROM}"
git checkout -b "${branch}"
git push "${GIT_REMOTE}" "${branch}"
)
fi
done