From 2510e6ac41b215dc3bf95193f01cbbe06b420151 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 8 Apr 2021 11:18:20 -0700 Subject: [PATCH] fix: check upstream before running script --- ci/build/release-prep.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ci/build/release-prep.sh b/ci/build/release-prep.sh index 4cea80a70..4e30a2fd1 100755 --- a/ci/build/release-prep.sh +++ b/ci/build/release-prep.sh @@ -68,6 +68,17 @@ main() { exit fi + # Note: we need to set upstream as well or the gh pr create step will fail + # See: https://github.com/cli/cli/issues/575 + CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-) + if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then + echo "Doesn't look like you've pushed this branch to remote" + # Note: we need to set upstream as well or the gh pr create step will fail + # See: https://github.com/cli/cli/issues/575 + echo "Please set the upstream and then run the script" + exit 1 + fi + # credit to jakwuh for this solution # https://gist.github.com/DarrenN/8c6a5b969481725a4413#gistcomment-1971123 CODE_SERVER_CURRENT_VERSION=$(node -pe "require('./package.json').version") @@ -90,18 +101,6 @@ main() { $CMD git commit -am "chore(release): bump version to $CODE_SERVER_VERSION_TO_UPDATE" - # Note: we need to set upstream as well or the gh pr create step will fail - # See: https://github.com/cli/cli/issues/575 - CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-) - if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then - echo "Doesn't look like you've pushed this branch to remote" - echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n" - # Note: we need to set upstream as well or the gh pr create step will fail - # See: https://github.com/cli/cli/issues/575 - echo "Please set the upstream and re-run the script" - exit 1 - fi - # This runs from the root so that's why we use this path vs. ../../ RELEASE_TEMPLATE_STRING=$(cat ./.github/PULL_REQUEST_TEMPLATE/release_template.md)