-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpackage-and-upload.sh
executable file
·108 lines (75 loc) · 1.98 KB
/
package-and-upload.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
100
101
102
103
104
105
106
107
108
#!/bin/bash
#
# This script should be invoked AFTER « gulp dist » was manually invoked.
# It does not run the tests or verify the lint. But it...
#
# 1. ... invokes Gulp to build the distribution.
# 2. ... makes a ZIP of the distribution.
# 3. ... uploads it to Bintray.
#
# Constants
readonly BINTRAY_URL="https://bintray.com/api/v1"
readonly DIRECTORY="target/dist"
readonly CONFIG="target/dev.config"
readonly BACKUP="target/dev.config.backup"
echo
echo "Verifying the parameters and the build directory..."
echo
if [ -z $1 ]; then
echo "The version parameter is mandatory."
echo "Usage: package-and-upload.sh <version>"
echo "Use 'snapshot' for ANY snapshot version."
exit 1
fi
if [ -d "$CONFIG" ]; then
echo "$CONFIG cannot exist for releases and uploads!"
echo "Renaming it to $BACKUP."
mv $CONFIG $BACKUP || exit 1
fi
echo
echo "Compiling the project..."
echo
ZIP="roboconf-web-administration-$1.zip"
rm -f $ZIP
gulp embed
if [ -d "$BACKUP" ]; then
echo
echo "Restoring the development configuration..."
echo
mv $BACKUP $CONFIG || exit 1
echo "Done."
fi
echo
echo "Zipping the content..."
echo
now=$(date +"%m/%d/%Y @ %H:%M:%S")
cd "$DIRECTORY" \
&& echo "Build and ZIP time: $now" > metadata.txt \
&& zip -rq "../$ZIP" . \
&& cd ..
echo "Done."
if [ "$1" == "snapshot" ]; then
echo
echo "Resetting the snapshot version..."
echo
curl -vvf -u${BINTRAY_USER}:${BINTRAY_API_KEY} \
-X DELETE ${BINTRAY_URL}/packages/roboconf/roboconf-web-administration/archives/versions/snapshot
echo "Done."
fi
echo
echo "Uploading the ZIP file to Bintray..."
echo
curl -X PUT -T $ZIP -u ${BINTRAY_USER}:${BINTRAY_API_KEY} \
-H "X-Bintray-Package:archives" \
-H "X-Bintray-Version:$1" \
-H "X-Bintray-Publish:1" \
-H "X-Bintray-Override:1" \
-H "X-Bintray-Explode:0" \
-# -o "/tmp/curl-output.txt" \
${BINTRAY_URL}/content/roboconf/roboconf-web-administration/$1/
echo
echo "$(</tmp/curl-output.txt)"
echo
if [[ "$(</tmp/curl-output.txt)" != *success* ]]; then
exit 1
fi