Skip to content

Commit

Permalink
release: Add convenience script for branch cutting
Browse files Browse the repository at this point in the history
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 <[email protected]>

Pull Request resolved: pytorch#72219
Approved by: https://github.com/malfet, https://github.com/atalman
  • Loading branch information
seemethere authored and pytorchmergebot committed Mar 15, 2022
1 parent 6b92abe commit ddb34e7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 9 deletions.
30 changes: 21 additions & 9 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`):

An example of this would look like:
```bash
DRY_RUN=disabled scripts/release/cut-release-branch.sh
```
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`
Expand All @@ -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:
Expand Down
49 changes: 49 additions & 0 deletions scripts/release/cut-release-branch.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ddb34e7

Please sign in to comment.