/
s3-download
executable file
·53 lines (49 loc) · 1.19 KB
/
s3-download
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
#!/usr/bin/env bash
#
# Downloads cross-compiled go executables for bundling inside platform-
# specific packages such as gem, jar, npm module etc.
#
# If the files are available locally, they are copied. If not, they
# are downloaded from S3.
#
set -euf -o pipefail
basename=$1
version=$2
baseurl=https://s3.eu-west-2.amazonaws.com/io.cucumber
rm -rf "${basename}"
mkdir "${basename}"
# Loop over all platforms that gox builds
for platform in \
darwin-386 \
darwin-amd64 \
freebsd-386 \
freebsd-amd64 \
freebsd-arm \
linux-386 \
linux-amd64 \
linux-arm \
linux-mips \
linux-mips64 \
linux-mips64le \
linux-mipsle \
linux-s390x \
netbsd-386 \
netbsd-amd64 \
netbsd-arm \
openbsd-386 \
openbsd-amd64 \
windows-386.exe \
windows-amd64.exe
do
src_url="${baseurl}/${basename}/${version}/${basename}-${platform}"
src_file="../go/dist/${basename}-${platform}"
file="${basename}/${basename}-${platform}"
if [ -e ${src_file} ]; then
cp ${src_file} ${file}
else
# cURL occasionaly fails. Try up to 3 times with a 5 sec sleep in-betweeen.
for i in 1 2 3; do
curl "${src_url}" -o "${file}" && chmod +x "${file}" && break || sleep 5;
done
fi
done