From 8a3b6cae4b3b80ec89137d2959cc5a9b9596265f Mon Sep 17 00:00:00 2001 From: Etienne Date: Mon, 26 Aug 2024 11:50:36 -0400 Subject: [PATCH] Crash release.sh when an error occur --- release.sh | 86 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/release.sh b/release.sh index 99039ff3a..7c1b66acd 100755 --- a/release.sh +++ b/release.sh @@ -1,26 +1,27 @@ #!/bin/bash +set -e VERSION=$1 shift CLOUD=($@) if [ -z "$VERSION" ]; then - echo "Specify the release version number" - echo "Usage: release.sh VERSION" - exit 1 + echo "Specify the release version number" + echo "Usage: release.sh VERSION" + exit 1 fi if [ -z "$CLOUD" ]; then - CLOUD=(aws azure gcp openstack ovh) + CLOUD=(aws azure gcp openstack ovh) fi if [ "$(uname)" == "Linux" ]; then - sed_i () { - sed -i "$@" - } + sed_i() { + sed -i "$@" + } elif [ "$(uname)" == "Darwin" ]; then - sed_i () { - sed -i "" "$@" - } + sed_i() { + sed -i "" "$@" + } fi TMPDIR=$(mktemp -d) @@ -28,39 +29,40 @@ FOLDER=$TMPDIR/magic_castle-$VERSION mkdir -p releases for provider in "${CLOUD[@]}"; do - cur_folder=$FOLDER/magic_castle-$provider-$VERSION - mkdir -p $cur_folder - cp -RfL common $cur_folder/ - rm $cur_folder/common/{variables,outputs}.tf - cp -RfL dns $cur_folder/ - cp -RfL $provider $cur_folder/ - cp -fL examples/$provider/main.tf $cur_folder - mv $cur_folder/$provider/README.md $cur_folder - sed_i 's;git::https://github.com/ComputeCanada/magic_castle.git//;./;g' $cur_folder/main.tf - sed_i "s;\"main\";\"$VERSION\";" $cur_folder/main.tf - cp LICENSE $cur_folder + cur_folder=$FOLDER/magic_castle-$provider-$VERSION + mkdir -p $cur_folder + cp -RfL common $cur_folder/ + rm $cur_folder/common/{variables,outputs}.tf + cp -RfL dns $cur_folder/ + cp -RfL $provider $cur_folder/ + cp -fL examples/$provider/main.tf $cur_folder + mv $cur_folder/$provider/README.md $cur_folder + sed_i 's;git::https://github.com/ComputeCanada/magic_castle.git//;./;g' $cur_folder/main.tf + sed_i "s;\"main\";\"$VERSION\";" $cur_folder/main.tf + cp LICENSE $cur_folder - ## Initialize to create .terraform.lock.hcl file - cd $cur_folder - ## Make sure only one module is named "dns" - sed_i '1,/dns/s/dns/cloudflare/' main.tf - ## Uncomment DNS modules - sed_i 's/^#\ //g' main.tf - # TODO: skip plugins download once Terraform issue #25813 is fixed - terraform init - rm -rf .terraform - cd - + ## Initialize to create .terraform.lock.hcl file + cd $cur_folder + ## Make sure only one module is named "dns" + sed_i '1,/dns/s/dns/cloudflare/' main.tf + ## Uncomment DNS modules + sed_i 's/^#\ //g' main.tf + # TODO: skip plugins download once Terraform issue #25813 is fixed + terraform init + rm -rf .terraform + cd - - ## Recreate a new unmodified main.tf - cp -fL examples/$provider/main.tf $cur_folder - sed_i 's;git::https://github.com/ComputeCanada/magic_castle.git//;./;g' $cur_folder/main.tf - sed_i "s;\"main\";\"$VERSION\";" $cur_folder/main.tf + ## Recreate a new unmodified main.tf + cp -fL examples/$provider/main.tf $cur_folder + sed_i 's;git::https://github.com/ComputeCanada/magic_castle.git//;./;g' $cur_folder/main.tf + sed_i "s;\"main\";\"$VERSION\";" $cur_folder/main.tf - cd $FOLDER - tar czvf magic_castle-$provider-$VERSION.tar.gz magic_castle-$provider-$VERSION - zip magic_castle-$provider-$VERSION.zip -r magic_castle-$provider-$VERSION - cd - - cp $FOLDER/magic_castle-$provider-$VERSION.tar.gz releases/ - cp $FOLDER/magic_castle-$provider-$VERSION.zip releases/ + cd $FOLDER + tar czvf magic_castle-$provider-$VERSION.tar.gz magic_castle-$provider-$VERSION + zip magic_castle-$provider-$VERSION.zip -r magic_castle-$provider-$VERSION + cd - + cp $FOLDER/magic_castle-$provider-$VERSION.tar.gz releases/ + cp $FOLDER/magic_castle-$provider-$VERSION.zip releases/ done -rm -rf $TMPDIR \ No newline at end of file +rm -rf $TMPDIR +