-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathgithub_release.sh
executable file
·57 lines (46 loc) · 1.82 KB
/
github_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
#!/bin/bash
set -ex
function upload() {
bin_name=$1
upload_name=$2
echo "Building ${upload_name}..."
pushd $GOPATH/bin
tar -czvf "/tmp/${upload_name}" $bin_name || exit 1
popd
echo "Computing checksum..."
pushd /tmp
cksum="${upload_name}.sha256"
sha256sum "${upload_name}" > ${cksum} || exit 1
popd
echo "Uploading release asset: ${upload_name}"
GH_ASSET="https://uploads.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases/${GITHUB_RELEASE_ID}/assets?name=${upload_name}"
curl --progress-bar -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" -H "Content-Type: application/octet-stream" $GH_ASSET -T "/tmp/${upload_name}" | jq
echo "Uploading the asset's checksum: ${upload_name}.sha256"
GH_CHECKSUM="https://uploads.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases/${GITHUB_RELEASE_ID}/assets?name=${upload_name}.sha256"
curl --progress-bar -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" -H "Content-Type: application/octet-stream" $GH_CHECKSUM -T "/tmp/${cksum}" | jq
}
GITHUB_OWNER="NVIDIA"
GITHUB_REPO="aistore"
echo "Fetching release id for the release tag: ${GITHUB_RELEASE_TAG}"
GITHUB_RELEASE_ID=$(curl -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" "https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases/tags/${GITHUB_RELEASE_TAG}" | jq '.id')
# Building the binaries
# TODO: add cross-platform support including macOS.
os="linux"
arch="amd64"
echo "Building binaries"
pushd ../
make cli
make aisloader
make authn
popd
echo "Checking if jq is installed"
if ! command -v jq 2>&1 /dev/null; then
sudo apt-get install jq
fi
echo "Checking if sha256sum is installed"
if ! command -v sha256sum 2>&1 /dev/null; then
sudo apt-get install coreutils
fi
upload ais "ais-${os}-${arch}.tar.gz"
upload authn "authn-${os}-${arch}.tar.gz"
upload aisloader "aisloader-${os}-${arch}.tar.gz"