github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/scripts/github_release.sh (about) 1 #!/bin/bash 2 set -ex 3 4 function upload() { 5 bin_name=$1 6 upload_name=$2 7 8 echo "Building ${upload_name}..." 9 pushd $GOPATH/bin 10 tar -czvf "/tmp/${upload_name}" $bin_name || exit 1 11 popd 12 13 echo "Computing checksum..." 14 pushd /tmp 15 cksum="${upload_name}.sha256" 16 sha256sum "${upload_name}" > ${cksum} || exit 1 17 popd 18 19 echo "Uploading release asset: ${upload_name}" 20 GH_ASSET="https://uploads.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases/${GITHUB_RELEASE_ID}/assets?name=${upload_name}" 21 curl --progress-bar -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" -H "Content-Type: application/octet-stream" $GH_ASSET -T "/tmp/${upload_name}" | jq 22 23 echo "Uploading the asset's checksum: ${upload_name}.sha256" 24 GH_CHECKSUM="https://uploads.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases/${GITHUB_RELEASE_ID}/assets?name=${upload_name}.sha256" 25 curl --progress-bar -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" -H "Content-Type: application/octet-stream" $GH_CHECKSUM -T "/tmp/${cksum}" | jq 26 } 27 28 GITHUB_OWNER="NVIDIA" 29 GITHUB_REPO="aistore" 30 echo "Fetching release id for the release tag: ${GITHUB_RELEASE_TAG}" 31 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') 32 33 # Building the binaries 34 # TODO: add cross-platform support including macOS. 35 os="linux" 36 arch="amd64" 37 echo "Building binaries" 38 pushd ../../ 39 make cli 40 make aisloader 41 make authn 42 popd 43 44 echo "Checking if jq is installed" 45 if ! command -v jq 2>&1 /dev/null; then 46 sudo apt-get install jq 47 fi 48 49 echo "Checking if sha256sum is installed" 50 if ! command -v sha256sum 2>&1 /dev/null; then 51 sudo apt-get install coreutils 52 fi 53 54 55 upload ais "ais-${os}-${arch}.tar.gz" 56 upload authn "authn-${os}-${arch}.tar.gz" 57 upload aisloader "aisloader-${os}-${arch}.tar.gz"