forked from livepeer/go-livepeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_build.sh
executable file
·58 lines (49 loc) · 1.9 KB
/
upload_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# CI script for uploading builds.
set -e
set -o nounset
if [[ $(uname) == *"MSYS2_NT"* ]]; then
ARCH="windows"
EXT=".exe"
else
ARCH=$(uname | tr '[:upper:]' '[:lower:]')
EXT=""
fi
BASE="livepeer-$ARCH-amd64"
BRANCH="${TRAVIS_BRANCH:-${CIRCLE_BRANCH:-unknown}}"
VERSION="$(cat VERSION)-$(git describe --always --long --abbrev=8 --dirty)"
mkdir $BASE
cp ./livepeer${EXT} $BASE
cp ./livepeer_cli${EXT} $BASE
# do a basic upload so we know if stuff's working prior to doing everything else
if [[ $ARCH == "windows" ]]; then
FILE=$BASE.zip
# This list was produced by `ldd livepeer.exe`
LIBS="libffi-6.dll libgcc_s_seh-1.dll libgmp-10.dll libgnutls-30.dll libhogweed-4.dll libiconv-2.dll libidn2-0.dll libintl-8.dll libnettle-6.dll libp11-kit-0.dll libtasn1-6.dll libunistring-2.dll libwinpthread-1.dll zlib1.dll"
for LIB in $LIBS; do
cp -r /mingw64/bin/$LIB ./$BASE
done
zip -r ./$FILE ./$BASE
else
FILE=$BASE.tar.gz
tar -czvf ./$FILE ./$BASE
fi
if [[ "${GCLOUD_KEY:-}" == "" ]]; then
echo "GCLOUD_KEY not found, not uploading to Google Cloud."
exit 0
fi
# https://stackoverflow.com/a/44751929/990590
bucket=build.livepeer.live
resource="/${bucket}/${VERSION}/${FILE}"
contentType="application/x-compressed-tar"
dateValue=`date -R`
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${GCLOUD_SECRET} -binary | base64`
curl -X PUT -T "${FILE}" \
-H "Host: storage.googleapis.com" \
-H "Date: ${dateValue}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: AWS ${GCLOUD_KEY}:${signature}" \
https://storage.googleapis.com${resource}
curl --fail -s -H "Content-Type: application/json" -X POST -d "{\"content\": \"Build succeeded ✅\nBranch: $BRANCH\nPlatform: $ARCH-amd64\nLast commit: $(git log -1 --pretty=format:'%s by %an')\nhttps://build.livepeer.live/$VERSION/${FILE}\"}" $DISCORD_URL 2>/dev/null
echo "done"