forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Pull Request resolved: pytorch#72219 Approved by: https://github.com/malfet, https://github.com/atalman
- Loading branch information
1 parent
6b92abe
commit ddb34e7
Showing
2 changed files
with
70 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |