From bd798bc35f81f43982584e8fb233f4941bd62e20 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Thu, 1 Jun 2023 14:15:39 +0100 Subject: [PATCH] Added Bundle udpate script --- bundle_update.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 bundle_update.sh diff --git a/bundle_update.sh b/bundle_update.sh new file mode 100755 index 0000000..8066a37 --- /dev/null +++ b/bundle_update.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Best practice options +set -o nounset +set -o pipefail +if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi + +if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then + echo 'Usage: +' + exit +fi + +declare -a UPDATE_LEVELS=(patch minor major) + +dip test +if [ $? -ne 0 ]; then + echo "Tests failed prior to updating any gems. Exiting." + exit +fi + +DATE=`date "+%F"` +git checkout -b "bundle_update_$DATE" + +for level in "${UPDATE_LEVELS[@]}"; do + dip bundle update --$level + dip test + if [ $? -ne 0 ]; then + echo "Tests failed after $level update, rolling those changes back." + git restore . + break + else + echo "Tests passed after $level update, committing changes." + git add -A + git commit -m "Successful automatic $level update" + fi +done + +git push -u origin $(git symbolic-ref --short HEAD) -o merge_request.create # Create remote branch