-
Notifications
You must be signed in to change notification settings - Fork 57
/
release.sh
executable file
·46 lines (37 loc) · 1.01 KB
/
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
#!/usr/bin/env bash
if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is empty." 1>&2
exit 1
fi
if [ ! -z "$CIRCLE_TAG" ]; then
TAG=$CIRCLE_TAG
fi
echo "TAG=$TAG"
curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"$TAG\",
\"target_commitish\": \"master\",
\"name\": \"$TAG\",
\"body\": \"$TAG\",
\"draft\": true,
\"prerelease\": true
}" \
https://api.github.com/repos/stormcat24/protodep/releases > .tag.json
if [ $? -ne 0 ]; then
echo "create release failed." 1>&2
exit 1
fi
UPLOAD_URL=`cat .tag.json | grep upload_url | sed -e "s/\s*\"upload_url\": \"//" | sed -e "s/\",//" | sed -e "s/{?name,label}/?name=/" | sed -e "s/ //"`
echo "UPLOAD_URL=$UPLOAD_URL"
for file in `ls artifacts`
do
curl --data-binary @artifacts/$file \
-H "Content-Type: application/x-gzip" \
-H "Authorization: token $GITHUB_TOKEN" $UPLOAD_URL$file
if [ $? -ne 0 ]; then
echo "upload artifact failed." 1>&2
exit 1
fi
done