diff --git a/release b/release index 216141253..5b9db5de7 100755 --- a/release +++ b/release @@ -78,6 +78,14 @@ if ! command -v curl >/dev/null 2>&1 ; then error "the 'curl' command was not found, please install it" fi +# helper function for parsing GitHub's JSON output. Right now, +# we only extract the value of a single key at a time. This means +# we may end up parsing the same JSON data two times, but that +# doesn't really matter as it is tiny. +json_get_key() { + echo "$response" | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("'"$1"'",""))' +} + ###################################################################### # # Command line processing @@ -204,7 +212,7 @@ if [ x"$REPO" = "x" ] ; then fi notice "Using GitHub repository $REPO" -API_URL=https://api.github.com/repos/$REPO +API_URL=https://api.github.com/repos/$REPO/releases UPLOAD_URL=https://uploads.github.com/repos/$REPO/releases ###################################################################### @@ -323,7 +331,7 @@ function jsonval { } # check if release already exists -response=$(curl -s -S -X GET $API_URL/tags/$TAG?access_token=$TOKEN) +response=$(curl -s -S -X GET "$API_URL/tags/$TAG" -H "Authorization: token $TOKEN") # echo ${response} if echo "${response}" | fgrep -q "Not Found" ; then notice "Release does not exist" @@ -331,7 +339,7 @@ else if [ x$FORCE = xyes ] ; then notice "Deleting existing release $TAG from GitHub" RELEASE_ID=$(jsonval | sed "s/id:/\n/g" | sed -n 2p | sed "s| ||g") - response=$(curl -s -S -X DELETE $API_URL/releases/$RELEASE_ID?access_token=$TOKEN) + response=$(curl -s -S -X DELETE "$API_URL/$RELEASE_ID" -H "Authorization: token $TOKEN") else error "release $TAG already exists on GitHub, aborting (use --force to override this)" fi @@ -348,9 +356,16 @@ define DATA <