-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupload_binaries.sh
99 lines (82 loc) · 3.48 KB
/
upload_binaries.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" == "master" ]; then
# define some variables
GH_USER=skiwi2
GH_REPO=TCG
BUILD_NAME=TCG
BUILD_VERSION=1.0-SNAPSHOT
# 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/${GH_USER}/${GH_REPO}/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'`
# default to 1 if nothing was found
if [ "$ID_TO_DELETE" == "" -o "$ID_TO_DELETE" == "null" ]; then
echo -e "Defaulting to release id 1"
ID_TO_DELETE=1
fi
# delete previous release
echo -e "Deleting release number ${ID_TO_DELETE}\n"
curl -X DELETE -H "Authorization: token ${GH_TOKEN}" \
"https://api.github.com/repos/${GH_USER}/${GH_REPO}/releases/${ID_TO_DELETE}"
# delete previous tag
echo -e "Deleting latest-master tag\n"
curl -X DELETE -H "Authorization: token ${GH_TOKEN}" \
"https://api.github.com/repos/${GH_USER}/${GH_REPO}/git/refs/tags/latest-master"
echo -e "Creating a release\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-d '{"tag_name": "latest-master", "target_commitish": "master", "name": "master-'${TRAVIS_BUILD_NUMBER}'", "body": "Automatic release based on latest commit to master branch generated by Travis CI.", "draft": false, "prerelease": true}' "https://api.github.com/repos/${GH_USER}/${GH_REPO}/releases" > json.txt
IDDI=`cat json.txt | jq '.id'`
echo -e "Release identifier ${IDDI}"
# build JavaFX JAR file
mvn clean jfx:jar
# print all files in target directory
echo -e "\nPrinting files in target directory:"
for filename in /home/travis/build/${GH_USER}/${GH_REPO}/target/*
do
if [ -f "$filename" ]; then
actualsize=$(wc -c "$filename" | cut -f 1 -d ' ')
echo "${filename} (${actualsize} bytes)"
else
echo "${filename}"
fi
done;
# print all files in target/jfx directory
echo -e "\nPrinting files in target/jfx directory:"
for filename in /home/travis/build/${GH_USER}/${GH_REPO}/target/jfx/*
do
if [ -f "$filename" ]; then
actualsize=$(wc -c "$filename" | cut -f 1 -d ' ')
echo "${filename} (${actualsize} bytes)"
else
echo "${filename}"
fi
done;
# print all files in target/jfx/app directory
echo -e "\nPrinting files in target/jfx/app directory:"
for filename in /home/travis/build/${GH_USER}/${GH_REPO}/target/jfx/app/*
do
if [ -f "$filename" ]; then
actualsize=$(wc -c "$filename" | cut -f 1 -d ' ')
echo "${filename} (${actualsize} bytes)"
else
echo "${filename}"
fi
done;
echo -e "Uploading JAR\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @/home/travis/build/${GH_USER}/${GH_REPO}/target/jfx/app/${BUILD_NAME}-${BUILD_VERSION}-jfx.jar \
"https://uploads.github.com/repos/${GH_USER}/${GH_REPO}/releases/${IDDI}/assets?name=${BUILD_NAME}-${TRAVIS_BRANCH}-${TRAVIS_BUILD_NUMBER}.jar"
echo -e "Done uploading\n"
echo -e "Force draft status false on release {$IDDI}\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-d '{"draft": false}' "https://api.github.com/repos/${GH_USER}/${GH_REPO}/releases/${IDDI}" > json_force.txt
echo -e "Done\n"
fi
fi