-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.sh
executable file
·145 lines (129 loc) · 4.29 KB
/
build.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# Simple shell script to build and upload installers.
# This can only be used if you are on OSX and have s3cmd
# installed and configured with access keys.
# Extract VERSION from app/main.js
MAJOR=$(sed -n '/^main\.MAJOR =.*/p' app/main.js | cut -d' ' -f 3)
MINOR=$(sed -n '/^main\.MINOR =.*/p' app/main.js | cut -d' ' -f 3)
PATCH=$(sed -n '/^main\.PATCH =.*/p' app/main.js | cut -d' ' -f 3)
BUILD=$(sed -n '/^main\.BUILD =.*/p' app/main.js | cut -d"\"" -f 2)
if [ ! -z "$BUILD" ] ; then
VER=$MAJOR.$MINOR.$PATCH-$BUILD
else
VER=$MAJOR.$MINOR.$PATCH
fi
export NAME=evothings-studio
# Default is all three, empty
PLATFORM=
function usage {
cat <<ENDOFHELP
Usage: $0 [-wvolauh?]
-w Build Windows
-v Build Windows32
-o Build OSX
-l Build Linux
-a Build all
-u Upload to S3
-h -? Show this help.
ENDOFHELP
exit 1;
}
# No arguments
if [ -z "$1" ] ; then
usage
exit 1
fi
# Read global options and shift them away
while getopts "wvolauh?" o; do
case "$o" in
w)
DOBUILD=true
PLATFORM=win;;
v)
DOBUILD=true
PLATFORM=win32;;
o)
DOBUILD=true
PLATFORM=mac;;
l)
DOBUILD=true
PLATFORM=linux;;
u) DOUPLOAD=true;;
a) DOBUILD=true;;
h) usage;;
[?]) usage;;
esac
done
#shift $(($OPTIND - 1))
if [ ! -z "$DOBUILD" ] ; then
echo "Checking missing npm packages ..."
npm-install-missing
cd app
npm-install-missing
cd ..
echo "Building version $VER ..."
# Burn in build timestamp
NOW=$(date)
sed -i '' -e "s/main\.TIMESTAMP = '<timestamp>'/main\.TIMESTAMP = '$NOW'/g" ./app/main.js
# Nuke old builds
rm -rf dist/*
fi
if [ -z "$PLATFORM" ] || [ "$PLATFORM" == "linux" ] ; then
npm run dist:linux
if [ ! -z "$DOUPLOAD" ] ; then
# Upload deb, rpm, AppImage
mv dist/*.deb dist/$NAME-$VER.deb
s3cmd put dist/*.deb s3://evothings-download/
s3cmd put dist/*.rpm s3://evothings-download/
mv dist/*.AppImage dist/$NAME-$VER.AppImage
s3cmd put dist/*.AppImage s3://evothings-download/
s3cmd setacl --acl-public s3://evothings-download/$NAME-$VER.deb
s3cmd setacl --acl-public s3://evothings-download/$NAME-$VER.rpm
s3cmd setacl --acl-public s3://evothings-download/$NAME-$VER.AppImage
fi
fi
if [ -z "$PLATFORM" ] || [ "$PLATFORM" == "win" ] ; then
npm run dist:win
if [ ! -z "$DOUPLOAD" ] ; then
# Upload (rename) Windows Squirrel and NSIS installer
cp dist/win/Evothings\ Studio\ Setup\ $VER.exe /tmp/$NAME-$VER.exe
s3cmd put /tmp/$NAME-$VER.exe s3://evothings-download/
s3cmd setacl --acl-public s3://evothings-download/$NAME-$VER.exe
rm /tmp/$NAME-$VER.exe
cp dist/Evothings\ Studio\ Setup\ $VER.exe /tmp/$NAME-$VER-nsis.exe
s3cmd put /tmp/$NAME-$VER-nsis.exe s3://evothings-download/
s3cmd setacl --acl-public s3://evothings-download/$NAME-$VER-nsis.exe
rm /tmp/$NAME-$VER-nsis.exe
fi
fi
if [ -z "$PLATFORM" ] || [ "$PLATFORM" == "win32" ] ; then
npm run dist:win32
if [ ! -z "$DOUPLOAD" ] ; then
# Upload (rename) Windows installer
cp dist/win-ia32/Evothings\ Studio\ Setup\ $VER-ia32.exe /tmp/$NAME-$VER-ia32.exe
s3cmd put /tmp/$NAME-$VER-ia32.exe s3://evothings-download/
s3cmd setacl --acl-public s3://evothings-download/$NAME-$VER-ia32.exe
rm /tmp/$NAME-$VER-ia32.exe
fi
fi
if [ -z "$PLATFORM" ] || [ "$PLATFORM" == "mac" ] ; then
npm run dist:mac
if [ ! -z "$DOUPLOAD" ] ; then
# Upload (rename) OSX installer
cp dist/mac/Evothings\ Studio-$VER.dmg /tmp/$NAME-$VER.dmg
s3cmd put /tmp/$NAME-$VER.dmg s3://evothings-download/
s3cmd setacl --acl-public s3://evothings-download/$NAME-$VER.dmg
rm /tmp/$NAME-$VER.dmg
fi
fi
# Remove burn
sed -i '' -e "s/main\.TIMESTAMP = '.*'/main\.TIMESTAMP = '<timestamp>'/g" ./app/main.js
echo PASTE INTO GITTER:
echo https://s3-eu-west-1.amazonaws.com/evothings-download/$NAME-$VER.deb
echo https://s3-eu-west-1.amazonaws.com/evothings-download/$NAME-$VER.rpm
echo https://s3-eu-west-1.amazonaws.com/evothings-download/$NAME-$VER.AppImage
echo https://s3-eu-west-1.amazonaws.com/evothings-download/$NAME-$VER.dmg
echo https://s3-eu-west-1.amazonaws.com/evothings-download/$NAME-$VER.exe
echo https://s3-eu-west-1.amazonaws.com/evothings-download/$NAME-$VER-nsis.exe
echo https://s3-eu-west-1.amazonaws.com/evothings-download/$NAME-$VER-ia32.exe
echo "DONE"