From 22fd664bbe70d58bda25f7838c1ad8afc59ffb4a Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 16 Jul 2024 15:05:15 -0400 Subject: [PATCH 1/3] modify script for non main release --- scripts/publish.sh | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index ab06f99e..a3bbaff5 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -6,7 +6,7 @@ IFS=$'\n\t' echo_help() { cat << EOF USAGE: - ./scripts/publish.sh + ./scripts/publish.sh EOF } @@ -52,37 +52,32 @@ Remember to create a release on GitHub with a changelog notes: EOF } -if [ $# -gt 0 ]; then - # Show help message if -h, --help, or help passed - case $1 in - -h | --help | help) - echo_help - exit 0 - ;; - *) - echo "Invalid argument $1" - echo "" - echo_help - exit 1 - ;; - esac +if [ $# -ne 1 ]; then + echo "Error: Branch name is mandatory" + echo "" + echo_help + exit 1 fi +BRANCH_NAME=$1 + # Make sure our working dir is the repo root directory cd "$(git rev-parse --show-toplevel)" echo "Fetching git remotes" git fetch -GIT_STATUS=$(git status) +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if ! grep -q 'On branch main' <<< "$GIT_STATUS"; then - echo "Error! Must be on main branch to publish" +if [ "$CURRENT_BRANCH" != "$BRANCH_NAME" ]; then + echo "Error! Must be on branch '$BRANCH_NAME' to publish" exit 1 fi -if ! grep -q "Your branch is up to date with 'origin/main'." <<< "$GIT_STATUS"; then - echo "Error! Must be up to date with origin/main to publish" +GIT_STATUS=$(git status) + +if ! grep -q "Your branch is up to date with 'origin/$BRANCH_NAME'." <<< "$GIT_STATUS"; then + echo "Error! Must be up to date with origin/$BRANCH_NAME to publish" exit 1 fi From 8d7280d8d78031a7dfb9de61108ef5c0e5a8f368 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 16 Jul 2024 15:08:27 -0400 Subject: [PATCH 2/3] dont release from main --- scripts/publish.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index a3bbaff5..3c7d51d7 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -61,6 +61,11 @@ fi BRANCH_NAME=$1 +if [ "$BRANCH_NAME" = "main" ]; then + echo "Error! Cannot publish from the 'main' branch." + exit 1 +fi + # Make sure our working dir is the repo root directory cd "$(git rev-parse --show-toplevel)" @@ -99,9 +104,4 @@ echo "Tagging and publishing release" yarn -s --ignore-scripts publish --access=public echo "Pushing git commit and tag" -git push --follow-tags - -echo "Publish successful!" -echo "" - -create_github_release +git push From 378ea57068f2b4f238b6ff20a8406ded3b9153d7 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 16 Jul 2024 16:17:42 -0400 Subject: [PATCH 3/3] add missing lines --- scripts/publish.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 3c7d51d7..181d03ab 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -104,4 +104,9 @@ echo "Tagging and publishing release" yarn -s --ignore-scripts publish --access=public echo "Pushing git commit and tag" -git push +git push --follow-tags + +echo "Publish successful!" +echo "" + +create_github_release