Skip to content

Commit e1c3cd7

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

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

scripts/release/cut-release-branch.sh

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