Skip to content

Commit fcb9653

Browse files
committed
Add script to cut release branch
ghstack-source-id: a92689b Pull Request resolved: #2567
1 parent 12b5324 commit fcb9653

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

scripts/release/cut-release-branch.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
: '
9+
So you are looking to cut a release branch? Well you came
10+
to the right script.
11+
12+
This script can be used to cut any branch on any repository
13+
14+
For `pytorch/executorch` usage would be like:
15+
> DRY_RUN=disabled ./scripts/release/cut-release-branch.sh
16+
17+
or to cut from main branch:
18+
> DRY_RUN=disabled GIT_BRANCH_TO_CUT_FROM=main ./scripts/release/cut-release-branch.sh
19+
'
20+
21+
set -eou pipefail
22+
23+
GIT_TOP_DIR=$(git rev-parse --show-toplevel)
24+
GIT_REMOTE=${GIT_REMOTE:-origin}
25+
GIT_BRANCH_TO_CUT_FROM=${GIT_BRANCH_TO_CUT_FROM:-viable/strict}
26+
27+
# should output something like 1.11
28+
RELEASE_VERSION=${RELEASE_VERSION:-$(cut -d'.' -f1-2 "${GIT_TOP_DIR}/version.txt")}
29+
30+
DRY_RUN_FLAG="--dry-run"
31+
if [[ ${DRY_RUN:-enabled} == "disabled" ]]; then
32+
DRY_RUN_FLAG=""
33+
fi
34+
35+
36+
(
37+
set -x
38+
git fetch --all
39+
git checkout "${GIT_REMOTE}/${GIT_BRANCH_TO_CUT_FROM}"
40+
)
41+
42+
for branch in "release/${RELEASE_VERSION}" "orig/release/${RELEASE_VERSION}"; do
43+
if git rev-parse --verify "${branch}" >/dev/null 2>/dev/null; then
44+
echo "+ Branch ${branch} already exists, skipping..."
45+
continue
46+
else
47+
(
48+
set -x
49+
git checkout "${GIT_REMOTE}/${GIT_BRANCH_TO_CUT_FROM}"
50+
git checkout -b "${branch}"
51+
git push -q ${DRY_RUN_FLAG} "${GIT_REMOTE}" "${branch}"
52+
)
53+
fi
54+
done

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.2.0a0

0 commit comments

Comments
 (0)