forked from near/nearcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinary_release.sh
executable file
·72 lines (57 loc) · 2.5 KB
/
binary_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
#!/bin/bash
set -xeo pipefail
release="${1:-neard-release}"
case "$release" in
neard-release|nightly-release|perf-release|assertions-release)
;;
*)
echo "Unsupported release type '$release'. Please provide no argument for normal release or provide nightly-release for nightly."
exit 1
;;
esac
BRANCH=$(git branch --show-current)
# in case of Release triggered run, branch is empty
if [ -z "$BRANCH" ]; then
REF=$(git describe --tags | head -n1)
BRANCH=$(git branch -r --contains=$REF | head -n1 | cut -c3- | cut -d / -f 2)
fi
COMMIT=$(git rev-parse HEAD)
os=$(uname)
arch=$(uname -m)
os_and_arch=${os}-${arch}
function tar_binary {
mkdir -p $1/${os_and_arch}
cp target/release/$1 $1/${os_and_arch}/
tar -C $1 -czvf $1.tar.gz ${os_and_arch}
}
make $release
function upload_binary {
if [ "$release" = "neard-release" ]
then
tar_binary $1
tar_file=$1.tar.gz
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os}/${BRANCH}/$1
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os}/${BRANCH}/${COMMIT}/$1
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os}/${BRANCH}/${COMMIT}/stable/$1
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os_and_arch}/${BRANCH}/$1
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os_and_arch}/${BRANCH}/${COMMIT}/$1
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os_and_arch}/${BRANCH}/${COMMIT}/stable/$1
aws s3 cp --acl public-read ${tar_file} s3://build.nearprotocol.com/nearcore/${os_and_arch}/${BRANCH}/${tar_file}
aws s3 cp --acl public-read ${tar_file} s3://build.nearprotocol.com/nearcore/${os_and_arch}/${BRANCH}/${COMMIT}/${tar_file}
aws s3 cp --acl public-read ${tar_file} s3://build.nearprotocol.com/nearcore/${os_and_arch}/${BRANCH}/${COMMIT}/stable/${tar_file}
else
folder="${release%-release}"
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os}/${BRANCH}/${COMMIT}/${folder}/$1
aws s3 cp --acl public-read target/release/$1 s3://build.nearprotocol.com/nearcore/${os_and_arch}/${BRANCH}/${COMMIT}/${folder}/$1
fi
}
upload_binary neard
# disabled until we clarify why we need this binary in S3
# if [ "$release" != "assertions-release" ]
# then
# upload_binary store-validator
# fi
# if [ "$release" = "release" ]
# then
# upload_binary near-sandbox
# fi