-
Notifications
You must be signed in to change notification settings - Fork 12
/
upload_app.sh
executable file
·54 lines (46 loc) · 1.68 KB
/
upload_app.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
51
52
53
54
tar czf /Users/travis/build/subutai-io/control-center/SubutaiControlCenter.tar.gz /Users/travis/build/subutai-io/control-center/subutai_control_center_bin/SubutaiControlCenter.app
echo "Uploading SubutaiControlCenter.app"
BRANCH=$1
FILE=""
URL=""
upload_ipfs (){
filename=$1
user="[email protected]"
fingerprint="877B586E74F170BC4CF6ECABB971E2AC63D23DC9"
cdnHost=$2
echo $filename
extract_id()
{
id_src=$(echo $json | grep "id")
id=${id_src:10:46}
}
json=`curl -k -s -X GET ${cdnHost}/rest/v1/cdn/raw?name=$filename&latest`
echo "Received: $json"
extract_id
echo "Previous file ID is $id"
authId="$(curl -s ${cdnHost}/rest/v1/cdn/token?fingerprint=${fingerprint})"
echo "Auth id obtained and signed $authId"
sign="$(echo ${authId} | gpg --clearsign -u ${user})"
token="$(curl -s --data-urlencode "request=${sign}" ${cdnHost}/rest/v1/cdn/token)"
echo "Token obtained $token"
echo "Uploading file..."
upl_msg="$(curl -sk -H "token: ${token}" -Ffile=@$filename -Ftoken=${token} -X POST "${cdnHost}/rest/v1/cdn/uploadRaw")"
echo "$upl_msg"
echo "Removing previous"
echo $Upload
if [[ -n "$id" ]] && [[ $upl_msg != "An object with id: $id is exist in Bazaar. Increase the file version." ]]
then
curl -k -s -X DELETE "$cdnHost/rest/v1/cdn/raw?token=${token}&id=$id"
fi
echo -e "\\nCompleted"
}
FILE="/Users/travis/build/subutai-io/control-center/SubutaiControlCenter.tar.gz"
URL=https://devbazaar.subutai.io
if [[ $BRANCH != "master" ]] && [[ $BRANCH != "dev" ]]
then
upload_ipfs $FILE $URL
fi
echo "---------"
echo $FILE
echo $BRANCH
echo "---------"