Skip to content

Commit

Permalink
Release script now actually works!
Browse files Browse the repository at this point in the history
We were parsing the JSON wrong and thus truncating the upload URL.
  • Loading branch information
uliwitness committed Feb 21, 2019
1 parent 94526bc commit 558baac
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions upload_release.command
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ release='"tag_name": "v'"$VERSION_TAG"'", "target_commitish": "master", "name":
body=\"$DESCRIPTION\"
body='"body": '$body', '
release=$release$body
release=$release'"draft": true, "prerelease": '"$IS_PRERELEASE"
release=$release'"draft": false, "prerelease": '"$IS_PRERELEASE"
release='{'$release'}'
url="https://api.github.com/repos/$OWNER/$REPO/releases"

Expand All @@ -62,23 +62,26 @@ ARCHIVE_NAME="`basename ${ARCHIVE_PATH}`"

# $upload is like:
# "upload_url": "https://uploads.github.com/repos/:owner/:repo/releases/:ID/assets{?name,label}",
upload=$(echo "$upload" | egrep -o "\"upload_url\":[ \t]*\"(.+?)\"," | head -n 1)
upload=$(echo $upload | cut -d "\"" -f4 | cut -d "{" -f1)
upload="$upload?name=$ARCHIVE_NAME"
upload="$upload?name=${ARCHIVE_NAME}"
echo "Uploading to: $upload"

echo "$upload"

succ=$(curl -sSL -XPOST -H "Authorization: token $TOKEN" \
-H "Content-Length: $(stat -f %z $ARCHIVE_NAME)" \
succ=$(curl -L --post301 --post302 --post303 \
-H "Authorization: token $TOKEN" \
-H "Content-Type: $(file -b --mime-type $ARCHIVE_NAME)" \
--upload-file $ARCHIVE_NAME $upload)
-H "Accept: application/vnd.github.v3+json" \
--data-binary @${ARCHIVE_NAME} $upload)

echo "$succ"

download=$(echo $succ | egrep -o "browser_download_url.+?")
download=$(echo $succ | egrep -o "\"url\":[ \t]*\"(.+?)\"," | head -n 1)
if [[ $? -eq 0 ]]; then
echo `$download | cut -d: -f2,3 | cut -d\" -f2`
#open -a "Safari" "`$download | cut -d: -f2,3 | cut -d\" -f2`"
releaseurl="https://github.com/${OWNER}/${REPO}/releases/tag/${VERSION_TAG}"
echo "New release at: $releaseurl"
open -a "Safari" "$releaseurl"
else
echo Upload error!
echo "$download"
exit 2
fi

0 comments on commit 558baac

Please sign in to comment.