-
Notifications
You must be signed in to change notification settings - Fork 137
/
release.sh
executable file
·134 lines (122 loc) · 4.1 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# set version to whatever release is
# if ARM is set build ARM
# assumes a target root of arm-root
smoke_test()
{
cfg="$2"
cfg_binaries='"Boot": "output/platform/pc/boot/boot.img", "Kernel": "output/platform/pc/bin/kernel.img"'
image_name='webg-smoke-test'
instance_name="$image_name-`date +'%s'`"
tmp_file=output/test/smoke.json
server_port=8080
if [ -z $cfg ]; then # no provider-specific cloud configuration has ben supplied
cfg=${OPS_CONF} # use generic cloud configuration, if supplied
fi
if [ ! -z "$cfg" ]; then
if [ ! -f "$cfg" ]; then
echo Configuration file "$cfg" not found, aborting "$1" smoke test
return 1
fi
# Add bootloader and kernel files from this build to the user-supplied configuration
cfg=`cat "$cfg"`
cfg=${cfg%'}'}', '"$cfg_binaries"'}'
echo "$cfg" > $tmp_file
else
echo '{'"$cfg_binaries"'}' > $tmp_file
fi
cfg='-c '"$tmp_file"
res=0
echo 'Creating '"$1"' image '"$image_name"
ops image create -t "$1" output/test/runtime/bin/webg -i "$image_name" "$cfg"
if [ ! "$?" = "0" ]; then
echo "$1"' image creation failed'
if [ -z "$2" ]; then
echo 'Use can use the '"$3"' environment variable to specify a config.json file specific for '"$1"','
echo 'or OPS_CONF for a config.json file valid for all cloud providers'
fi
res=1
else
echo 'Creating '"$1"' instance '"$instance_name"
ops instance create -t "$1" "$image_name" -i "$instance_name" "$cfg" -p "$server_port"
if [ ! "$?" = "0" ]; then
echo "$1"' instance creation failed'
res=1
else
while true; do
instance_list=`ops instance list -t "$1" "$cfg"`
instance_rows=`echo "$instance_list" | grep "$instance_name"`
instance_row=`echo "$instance_rows" | grep -i running`
if [ "$?" = "0" ]; then
break
else
echo 'Waiting for instance to run...'
sleep 10
fi
done
list_header=`echo "$instance_list" | grep "PUBLIC IP"`
list_header=${list_header%*PUBLIC IP*}
separator_count=`echo "${list_header}" | awk -F'|' '{print NF-1}'`
# remove all characters up to the first $separator_count separators
# (i.e. remove any columns before public IP)
for i in `seq 1 $separator_count`
do
instance_row=${instance_row#*|}
done
# remove any columns after public IP
instance_ip=${instance_row%%|*}
# trim whitespace
instance_ip=`echo ${instance_ip##|*} | xargs`
ab -c 100 -n 1000 -dq http://"$instance_ip":"$server_port"/
if [ ! "$?" = "0" ]; then
echo "$1"' web server test failed'
res=2
fi
ops instance delete -t "$1" "$instance_name" "$cfg"
fi
ops image delete --assume-yes -t "$1" "$image_name" "$cfg"
fi
rm $tmp_file
return $res
}
if [ "$#" -ge 1 ]; then
if [ "$1" = 'smoke-test' ]; then
make target || exit 2
smoke_test "gcp" "${OPS_CONF_GCP}" "OPS_CONF_GCP" || exit 2
smoke_test "aws" "${OPS_CONF_AWS}" "OPS_CONF_AWS" || exit 2
echo Smoke tests completed successfully
else
echo Unknown command "$1"
exit 1
fi
fi
version=0.1.46
plat="$(uname -s | awk '{print tolower($0)}')"
tgz="nanos-release-$plat-$version.tar.gz"
hash="nanos-release-$plat-$version.md5"
rm "$tgz"
rm "$hash"
if [[ -n "${ARM}" ]]; then
echo "building for arm"
NANOS_TARGET_ROOT=arm-root
echo $NANOS_TARGET_ROOT
version="$version" PLATFORM=virt make release
mv release/"$tgz" release/"nanos-release-$plat-$version-virt.tar.gz"
tgz="nanos-release-$plat-$version-virt.tar.gz"
hash="nanos-release-$plat-$version-virt.md5"
else
version="$version" make release
fi
gsutil cp release/"$tgz" gs://nanos/release/"$version"/"$tgz"
gsutil setacl public-read gs://nanos/release/"$version"/"$tgz"
if [ "$plat" = 'darwin' ]
then
md5 -q release/"$tgz" > "$hash"
else
md5sum release/"$tgz" | awk '{print $1}' > "$hash"
fi
gsutil cp "$hash" gs://nanos/release/"$version"/"$hash"
gsutil setacl public-read gs://nanos/release/"$version"/"$hash"
echo "$version" > latest.txt
gsutil cp latest.txt gs://nanos/release/latest.txt
gsutil setacl public-read gs://nanos/release/latest.txt