From 0bb6cf4a4a1c66a494b8e123152da3a9b0381755 Mon Sep 17 00:00:00 2001 From: Dmitry Panin Date: Thu, 12 Dec 2013 01:53:46 +0400 Subject: [PATCH] Removing previous releases in order to upload new one --- upload-binaries.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/upload-binaries.sh b/upload-binaries.sh index d50697eb1..ea75298c7 100755 --- a/upload-binaries.sh +++ b/upload-binaries.sh @@ -34,6 +34,23 @@ fi if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then if [ "$TRAVIS_BRANCH" == "releasing-master" ]; then + + # get info about all releases + echo -e "Getting info about previous releases" + curl -X GET -H "Authorization: token ${GH_TOKEN}" \ + "https://api.github.com/repos/WagicProject/wagic/releases" > json.txt + + # extract info only about only "latest-release" tag + cat json.txt |jq 'map(select (.tag_name == "latest-master"))' > latest.txt + + # get id of release + ID_TO_DELETE=`cat latest.txt |jq '.[0].id'` + + # delete previous release + echo -e "Deleting release number ${ID_TO_DELETE}" + curl -X DELETE -H "Authorization: token ${GH_TOKEN}" \ + "https://api.github.com/repos/WagicProject/wagic/releases/${ID_TO_DELETE}" + echo -e "Creating a release\n" curl -X POST -H "Authorization: token ${GH_TOKEN}" \ -d '{"tag_name": "latest-master", "target_commitish": "master", "name": "Master branch release number '${TRAVIS_BUILD_NUMBER}'", "body": "Automatic release on master branch generated by Travis CI", "draft": false, "prerelease": true}' "https://api.github.com/repos/WagicProject/wagic/releases" > json.txt