-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathGH-Release.sh
executable file
·50 lines (41 loc) · 1.33 KB
/
GH-Release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -e
# create JSON
JSONTMP='/tmp/GH-Publish.json'
BASE_VERSION=0.1
COMMIT_NUMBER=`git rev-list HEAD --count`
VERSION="${BASE_VERSION}.${COMMIT_NUMBER}"
if [ -s GHTOKEN ]; then
TOKEN="`cat GHTOKEN`"
else
echo "Please put your Github API Token a file named \"GHTOKEN\""
exit 1
fi
cat >${JSONTMP} <<-!!EOF
{
"tag_name": "v${VERSION}",
"target_commitish": "master",
"name": "v${VERSION}",
"body": "Pre-Release of Ride 2.0",
"draft": false,
"prerelease": true
}
!!EOF
curl -o /tmp/GH-Response.json --data @${JSONTMP} -H "Authorization: token ${TOKEN}" -i https://api.github.com/repos/Dyalog/RideJS/releases
ReleaseID=`cat /tmp/GH-Response.json | grep "\"id\"" | head -1 | sed 's/.*: //;s/,//'`
echo "Created release with Id: ${ReleaseID}"
for DIR in `ls build/ride`; do
cd build/ride/${DIR}
echo "creating /tmp/Ride-${VERSION}-${DIR}.zip"
zip -q -r /tmp/Ride-${VERSION}-${DIR}.zip .
echo "uploading File..."
curl -o /dev/null -H "Authorization: token ${TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @/tmp/Ride-${VERSION}-${DIR}.zip \
"https://uploads.github.com/repos/Dyalog/RideJS/releases/${ReleaseID}/assets?name=Ride-${VERSION}-${DIR}.zip"
rm /tmp/Ride-${VERSION}-${DIR}.zip
cd -
done
rm /tmp/GH-Response.json
rm $JSONTMP