From 309add69c4e6f1c4dfca53080841fccfc3e61689 Mon Sep 17 00:00:00 2001 From: Nathan Wallach Date: Tue, 3 Aug 2021 11:22:17 +0300 Subject: [PATCH] Change the manner in which the token in sent to GitHub, as using access_token as a query parameter is deprecated. See: https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/ Instead use the Authorization HTTP header instead. Changes were made in the same manner as in gap-system/ReleaseTools@f8ce1aa#diff-a4d451ec23463726f72c43d64c710968f6b602cd653b4de8adee1b556240a829 on which @heiderich based the code. Also move the test of the ARCHIVE_FORMATS environment variable, so when it is necessary to abort, it is done very early on the process (in particular before running OPL-update). --- bin/OPL_releases/release.sh | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/bin/OPL_releases/release.sh b/bin/OPL_releases/release.sh index 24aca8b197..17d3abac3b 100755 --- a/bin/OPL_releases/release.sh +++ b/bin/OPL_releases/release.sh @@ -128,6 +128,25 @@ command -v python >/dev/null 2>&1 || cd $LIBRARY_DIR #verify_git_clean +###################################################################### +# +# Test whether ARCHIVE_FORMATS contains at least one valid format +# + +FOUND_VALID_FORMAT=0 +VALID_ARCHIVE_FORMATS='.tar.gz .tar.bz2 .zip' +for VALID_FORMAT in $VALID_ARCHIVE_FORMATS +do + if [[ $ARCHIVE_FORMATS =~ $VALID_FORMAT ]] + then + FOUND_VALID_FORMAT=1; + fi; +done; +if [[ $FOUND_VALID_FORMAT == "0" ]] +then + warning "No valid archive format specified. You should set an environment variable ARCHIVE_FORMATS before with suitable values before running the script." ; + exit 1; +fi; ###################################################################### # @@ -257,7 +276,7 @@ fi # # 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") MESSAGE=$(json_get_key message) RELEASE_ID=$(json_get_key id) @@ -267,7 +286,7 @@ elif [ x"$RELEASE_ID" != x ] ; then # release already exists -> error out or delete it if [ "x$FORCE" = xyes ] ; then notice "Deleting existing release $TAG from GitHub" - response=$(curl --fail -s -S -X DELETE "$API_URL/$RELEASE_ID?access_token=$TOKEN") + response=$(curl --fail -s -S -X DELETE "$API_URL/$RELEASE_ID" -H "Authorization: token $TOKEN") MESSAGE= else error "release $TAG already exists on GitHub, aborting (use --force to override this)" @@ -292,7 +311,7 @@ EOF notice "Creating new release $TAG on GitHub" response=$(curl -s -S -H "Content-Type: application/json" \ - -X POST --data "$DATA" "$API_URL?access_token=$TOKEN") + -X POST --data "$DATA" "$API_URL" -H "Authorization: token $TOKEN") MESSAGE=$(json_get_key message) if [ x"$MESSAGE" != x ] ; then @@ -304,25 +323,6 @@ if [ x"$RELEASE_ID" = x ] ; then fi -###################################################################### -# -# Test whether ARCHIVE_FORMATS contains at least one valid format -# - -FOUND_VALID_FORMAT=0 -VALID_ARCHIVE_FORMATS='.tar.gz .tar.bz2 .zip' -for VALID_FORMAT in $VALID_ARCHIVE_FORMATS -do - if [[ $ARCHIVE_FORMATS =~ $VALID_FORMAT ]] - then - FOUND_VALID_FORMAT=1; - fi; -done; -if [[ $FOUND_VALID_FORMAT == "0" ]] -then - warning "No valid archive format specified." ; - exit 1; -fi; ###################################################################### #