-
Notifications
You must be signed in to change notification settings - Fork 38
/
release.sh
executable file
·67 lines (59 loc) · 1.9 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/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
fi
if [ -z "$CLOUD" ]; then
CLOUD=(aws azure gcp openstack ovh)
fi
if [ "$(uname)" == "Linux" ]; then
sed_i () {
sed -i "$@"
}
elif [ "$(uname)" == "Darwin" ]; then
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
## 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
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