From 89cb593888d90b94fee4cd3e8aee1317d31d8b99 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Tue, 27 Mar 2018 17:10:09 -0700 Subject: [PATCH 1/4] Chore: Only reset to upstream/master for major/minor releases --- build/release.sh | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/build/release.sh b/build/release.sh index 1669abc03..f29975290 100755 --- a/build/release.sh +++ b/build/release.sh @@ -12,11 +12,7 @@ major_release=false minor_release=false patch_release=false - -reset_to_master() { - # Update to latest code on GitHub master - git checkout master || return 1 - +reset_tags() { # Wipe tags git tag -l | xargs git tag -d || return 1 @@ -27,6 +23,32 @@ reset_to_master() { # Fetch latest code with tags git fetch --tags github-upstream || return 1; +} + + +reset_to_previous_version() { + if OLD_VERSION === "XXX"; then + echo "----------------------------------------------------------------------" + echo "Error while cleaning workspace!" + echo "----------------------------------------------------------------------" + return 1; + fi + + # Reset and fetch upstream with tags + reset_tags || return 1; + + # Reset to previous release version and clear unstashed changes + git reset --hard OLD_VERSION || return 1 + git clean -f || return 1 +} + + +reset_to_master() { + # Update to latest code on GitHub master + git checkout master || return 1 + + # Reset and fetch upstream with tags + reset_tags || return 1; # Reset to latest code and clear unstashed changes git reset --hard github-upstream/master || return 1 @@ -205,7 +227,13 @@ if ! push_new_release; then echo "Cleaning workspace by checking out master and removing tags" echo "----------------------------------------------------------------------" - if ! reset_to_master; then + + if $patch_release; then + # Only reset to previous version for patch releases + reset_to_previous_version || return 1 + + # Reset to upstream/master for major/minor releases + else if ! reset_to_master; then echo "----------------------------------------------------------------------" echo "Error while cleaning workspace!" echo "----------------------------------------------------------------------" From 980cc7a3fc6023b4a75f65ca1efbe047eb1458b7 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Thu, 29 Mar 2018 13:01:22 -0700 Subject: [PATCH 2/4] Chore: Ensure that the release script never pushes a blank release --- build/release.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build/release.sh b/build/release.sh index f29975290..1bdda7989 100755 --- a/build/release.sh +++ b/build/release.sh @@ -66,6 +66,14 @@ increment_version() { # Old version OLD_VERSION=$(./build/current_version.sh) + # The master branch should not match the previous release tag + if [[ $(git log --oneline ...v$OLD_VERSION) == "" ]] ; then + echo "----------------------------------------------------" + echo "Your release has no new commits!" + echo "----------------------------------------------------" + exit 1 + fi + if $major_release; then echo "----------------------------------------------------------------------" echo "Bumping major version..." From fa56f03c14c987b94ad9ce0bb293447485679fc9 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Fri, 30 Mar 2018 08:53:52 -0700 Subject: [PATCH 3/4] Chore: Add log statements to clarify where script is resetting to --- build/release.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build/release.sh b/build/release.sh index 1bdda7989..d41c7df5d 100755 --- a/build/release.sh +++ b/build/release.sh @@ -14,6 +14,9 @@ patch_release=false reset_tags() { # Wipe tags + echo "----------------------------------------------------------------------" + echo "Wiping local tags" + echo "----------------------------------------------------------------------" git tag -l | xargs git tag -d || return 1 # Add the upstream remote if it is not present @@ -22,6 +25,9 @@ reset_tags() { fi # Fetch latest code with tags + echo "----------------------------------------------------------------------" + echo "Fetching latest upstream code + tags" + echo "----------------------------------------------------------------------" git fetch --tags github-upstream || return 1; } @@ -38,6 +44,9 @@ reset_to_previous_version() { reset_tags || return 1; # Reset to previous release version and clear unstashed changes + echo "----------------------------------------------------------------------" + echo "Resetting to v" $OLD_VERSION + echo "----------------------------------------------------------------------" git reset --hard OLD_VERSION || return 1 git clean -f || return 1 } @@ -51,6 +60,9 @@ reset_to_master() { reset_tags || return 1; # Reset to latest code and clear unstashed changes + echo "----------------------------------------------------------------------" + echo "Resetting to upstream/master" + echo "----------------------------------------------------------------------" git reset --hard github-upstream/master || return 1 git clean -f || return 1 } From 81318ee5a8f07d0222ff458ed88d2dc0710d8d86 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Fri, 30 Mar 2018 11:17:39 -0700 Subject: [PATCH 4/4] Update: comments --- build/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release.sh b/build/release.sh index d41c7df5d..d15e8761e 100755 --- a/build/release.sh +++ b/build/release.sh @@ -78,7 +78,7 @@ increment_version() { # Old version OLD_VERSION=$(./build/current_version.sh) - # The master branch should not match the previous release tag + # The current branch should not match the previous release tag if [[ $(git log --oneline ...v$OLD_VERSION) == "" ]] ; then echo "----------------------------------------------------" echo "Your release has no new commits!"