forked from nanopack/redundis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·36 lines (29 loc) · 1.12 KB
/
build.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
#!/usr/bin/env bash
set -e
# try and use the correct MD5 lib (depending on user OS darwin/linux)
MD5=$(which md5 || which md5sum)
# build redundis
echo "Building REDUNDIS and uploading it to 's3://tools.nanopack.io/redundis'"
gox -osarch "darwin/amd64 linux/amd64 windows/amd64" -output="./build/{{.OS}}/{{.Arch}}/redundis"
# look through each os/arch/file and generate an md5 for each
echo "Generating md5s..."
for os in $(ls ./build); do
for arch in $(ls ./build/${os}); do
for file in $(ls ./build/${os}/${arch}); do
cat "./build/${os}/${arch}/${file}" | ${MD5} | awk '{print $1}' >> "./build/${os}/${arch}/${file}.md5"
done
done
done
# upload to AWS S3
echo "Uploading builds to S3..."
aws s3 sync ./build/ s3://tools.nanopack.io/redundis --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --region us-east-1
echo "Creating invalidation for cloudfront"
aws configure set preview.cloudfront true
aws cloudfront create-invalidation \
--distribution-id E3B5Z3LYG19QSL \
--paths /redundis
# remove build
echo "Cleaning up..."
[ -e "./build" ] && \
echo "Removing build files..." && \
rm -rf "./build"