servatrice/.ci/get_github_upload_url.sh
2020-11-22 20:20:48 -05:00

19 lines
519 B
Bash
Executable file

#!/bin/bash
# this script is to be used by the ci to fetch the github upload url
# using curl and jq
[[ $ref ]] || missing+=" ref"
[[ $repo ]] || missing+=" repo"
if [[ $missing ]]; then
echo "missing env:$missing" >&2
exit 2
fi
tag="${ref##*/}"
api_url="https://api.github.com/repos/$repo/releases/tags/$tag"
upload_url="$(curl "$api_url" | jq -r '.upload_url')"
if [[ $upload_url && $upload_url != null ]]; then
echo "$upload_url"
exit 0
else
echo "failed to fetch upload url from $api_url" >&2
exit 1
fi