forked from snobu/destreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_release.sh
executable file
·169 lines (134 loc) · 2.92 KB
/
make_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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
set -euo pipefail
cd ..
# vars
chromeRev=`cat node_modules/puppeteer/package.json | grep chromium_revision | grep -oP '"([0-9]+)"' | cut -d"\"" -f2`
baseUrl="https://storage.googleapis.com/chromium-browser-snapshots"
osAr=("Linux_x64" "Mac" "Win_x64")
zipAr=("linux" "mac" "win")
arg="all"
function checkWget() {
command -v wget >/dev/null 2>&1 || { echo -e >&2 "I need wget to work :(\n"; exit 1; }
}
function setupBuildForOS() {
case "$arg" in
"linux")
osAr=("Linux_x64")
zipAr=("linux")
;;
"win")
osAr=("Win_x64")
zipAr=("win")
;;
"macos")
osAr=("Mac")
zipAr=("mac")
;;
*)
echo -e "\nInvalid OS selected!\n"
exit 1
;;
esac;
}
function makeDirectories() {
if [ -d release ]; then
rm -R release
fi
mkdir -p release/temp
}
function buildDestreamer() {
npm run -s build
}
function downloadChromiumPackages() {
local idx=0
for os in "${osAr[@]}"
do
local zipName="chrome-${zipAr[$idx]}.zip"
local finalUrl="$baseUrl/$os/$chromeRev/$zipName"
wget "$finalUrl" -P "release/temp/$os"
unzip "release/temp/$os/$zipName" -d "release/temp/$os"
((++idx))
done;
}
function buildPkg() {
pkg . --out-path release
cd release
cp destreamer-linux temp/Linux_x64
cp destreamer-macos temp/Mac
cp destreamer-win.exe temp/Win_x64
}
function buildPkgForOS() {
pkg -t "$arg" . --out-path release
cd release
cp destreamer* "temp/${osAr[0]}"
}
function buildDestreamerReleasePackages() {
local idx=0
for os in "${osAr[@]}"
do
local chromeFold="chrome-${zipAr[$idx]}"
local osFolder="${zipAr[$idx]}-$chromeRev"
if [[ "$os" == "Win_x64" ]]; then # windows fix
osFolder="win64-$chromeRev"
fi;
cd "temp/$os"
mkdir -p "chromium/$osFolder"
mv "$chromeFold" "chromium/$osFolder"
zip -r "destreamer-$os.zip" chromium destreamer*
mv "destreamer-$os.zip" ../../..
cd ../..
((++idx))
done;
cd ..
}
function usage() {
echo -e "Usage: $0 [option]\n"
echo " help - Show usage"
echo " linux - Build for Linux x64"
echo " win - Build for Windows x64"
echo " macos - Build for MacOS x64"
echo " all - Build all"
echo -e "\n default: all\n"
}
function parseArgument() {
case "$arg" in
"all")
;;
"linux"|"win"|"macos")
setupBuildForOS
;;
*)
usage
exit 0
;;
esac;
}
function main() {
clear
echo "##############################"
echo "# Destreamer release builder #"
echo -e "##############################\n"
parseArgument
checkWget
echo -e "\n> \e[32mMaking directories...\e[39m"
makeDirectories
echo -e "\n> \e[32mBuilding destreamer...\e[39m"
buildDestreamer
echo -e "\n> \e[32mDownloading chromium packages...\e[39m"
downloadChromiumPackages
echo -e "\n> \e[32mBuilding pkg...\e[39m"
if [[ "$arg" == "all" ]]; then
buildPkg
else
buildPkgForOS
fi;
echo -e "\n> \e[32mBuilding destreamer release package\e[39m"
buildDestreamerReleasePackages
rm -R release
exit 0
}
# run
if [[ $# -gt 0 ]]; then
arg="$1"
fi;
main