forked from ibmresilient/resilient-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpushrelease.sh
More file actions
28 lines (18 loc) · 1.05 KB
/
pushrelease.sh
File metadata and controls
28 lines (18 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash -e
function getJsonVal() {
releaseID=`python -c "import json,sys;print json.dumps(json.loads('''$1''')$2); sys.exit(0);"` ;
echo $releaseID
}
echo Getting Git Tag...
latestTag=$(git describe --tags)
echo Creating release...
echo '{"tag_name": "'$latestTag'","target_commitish": "master","name": "Internal Release '$latestTag'","body": "Generated by Jenkins","draft": false,"prerelease": true}' > json.json
output=$(curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' --data-binary @json.json https://github.ibm.com/api/v3/repos/Resilient/resilient-python-api/releases?access_token=$GIT_HUB_AUTH_TOKEN)
rm json.json
id=$(getJsonVal "$output" "['id']")
echo Release Id: $id
for file in ./builds/*.tar.gz; do
echo Uploading file... ${file##*/}
fileUpload=$(curl --data-binary @./builds/${file##*/} -H "Authorization: token $GIT_HUB_AUTH_TOKEN" -H "Content-Type: application/octet-stream" https://github.ibm.com/api/uploads/repos/Resilient/resilient-python-api/releases/"$id"/assets?name=${file##*/} )
echo $fileUpload
done