Skip to content

Commit 87cd963

Browse files
authored
Automate replacing test-infra release branch (#4577)
Thanks to @atalman works in #4515 and @osalpekar example in https://github.com/pytorch/vision/pull/7929/files, this change applies the same step to test-infra to automate its release branch. From what I see in https://github.com/pytorch/test-infra/commits/release/2.1, this seems to be the only required steps to replace main with release branch. ### Testing Run `GIT_BRANCH_TO_CUT_FROM=main RELEASE_VERSION=2.1 DRY_RUN=disabled release/cut-release-branch.sh` to cut release branch for test-infra in my own fork repo https://github.com/huydhn/test-infra/commits/release/2.1 Fixes #4570
1 parent f4361f3 commit 87cd963

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

release/cut-release-branch.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,26 @@ GIT_BRANCH_TO_CUT_FROM=${GIT_BRANCH_TO_CUT_FROM:-viable/strict}
2121

2222
# should output something like 1.11
2323
RELEASE_VERSION=${RELEASE_VERSION:-$(cut -d'.' -f1-2 "${GIT_TOP_DIR}/version.txt")}
24+
TEST_INFRA_BRANCH=${TEST_INFRA_BRANCH:-"release/${RELEASE_VERSION}"}
2425

2526
DRY_RUN_FLAG="--dry-run"
2627
if [[ ${DRY_RUN:-enabled} == "disabled" ]]; then
2728
DRY_RUN_FLAG=""
2829
fi
2930

31+
function update_test_infra_branch() {
32+
# Change all GitHub Actions to reference the test-infra release branch
33+
# as opposed to main as copied from pytorch/vision/packaging/cut_release.sh
34+
for i in .github/workflows/*.yml; do
35+
if [[ "$OSTYPE" == "darwin"* ]]; then
36+
sed -i '' -e s#@main#@"${TEST_INFRA_BRANCH}"# $i;
37+
sed -i '' -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${TEST_INFRA_BRANCH}"# $i;
38+
else
39+
sed -i -e s#@main#@"${TEST_INFRA_BRANCH}"# $i;
40+
sed -i -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${TEST_INFRA_BRANCH}"# $i;
41+
fi
42+
done
43+
}
3044

3145
(
3246
set -x
@@ -43,7 +57,14 @@ for branch in "release/${RELEASE_VERSION}" "orig/release/${RELEASE_VERSION}"; do
4357
set -x
4458
git checkout "${GIT_REMOTE}/${GIT_BRANCH_TO_CUT_FROM}"
4559
git checkout -b "${branch}"
46-
git push "${GIT_REMOTE}" "${branch}"
60+
# Apply common steps to automate release
61+
update_test_infra_branch
62+
63+
if [[ "${DRY_RUN:-enabled}" == "disabled" ]]; then
64+
git add .github/workflows/*.yml
65+
git commit -m "[RELEASE-ONLY CHANGES] Branch Cut for Release ${RELEASE_VERSION}"
66+
git push "${GIT_REMOTE}" "${branch}"
67+
fi
4768
)
4869
fi
4970
done

0 commit comments

Comments
 (0)