-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Crash release.sh when an error occur
- Loading branch information
1 parent
1df9227
commit 8a3b6ca
Showing
1 changed file
with
44 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,68 @@ | ||
#!/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) | ||
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 | ||
rm -rf $TMPDIR | ||
|