compliance-operator/hack/upload-gh

44 lines
828 B
Bash
Executable File

#!/bin/bash
set -eo pipefail
BASE_DIR="build/bin"
function usage(){
echo "$0 <arch>"
exit 1
}
function check_input(){
[ -z "${TAG}" ] && echo "TAG is not set." && exit 1
return 0
}
function checksum_file(){
arch=$1
if [[ ! -f "${BASE_DIR}/compliance-operator-${arch}" ]]; then
echo "file ${BASE_DIR}/compliance-operator-${arch} not found"
exit 1
fi
sha256sum "${BASE_DIR}/compliance-operator-${arch}" | sed "s;${BASE_DIR}/;;g" \
> "${BASE_DIR}/sha256sum-${arch}.txt"
}
function upload_files(){
arch=$1
gh release upload "${TAG}" "${BASE_DIR}/compliance-operator-${arch}"
gh release upload "${TAG}" "${BASE_DIR}/sha256sum-${arch}.txt"
}
function main()
{
check_input
checksum_file "$1"
upload_files "$1"
}
[[ -z "$1" ]] && usage
main "$1"