-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·53 lines (47 loc) · 1.15 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
#!/bin/bash
set -Eeuo pipefail
if [ -d "built" ] ; then
rm -r -- built
fi
PACKAGE_VERSION=$( awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json)
function getHash(){
git rev-parse --short HEAD
}
echo "Building anyCiCd-$PACKAGE_VERSION #$(getHash)"
function pack(){
if [ ! -d "built" ] ; then
echo "build dir not found , abort packing.."
return
fi
cd built
for file in * ; do
mkdir "dir_$file"
mv "$file" "dir_$file/"
cp ../sample.env "dir_$file"
mkdir "dir_$file/exec"
mv "dir_$file" "$file"
zip -9 -r "$file.zip" "$file"
echo $file
done
}
function generic(){
npx pkg --config dist/package.json -o "./built/anyCiCd-$PACKAGE_VERSION-$(getHash)-generic" ./dist/bin/www.js
pack
}
function rpi(){
npx pkg --config rpi_build_conf.json -o "./built/anyCiCd-$PACKAGE_VERSION-$(getHash)-rpi" ./dist/bin/www.js
pack
}
case "$1" in
generic)
generic
exit
;;
rpi)
rpi
exit
;;
*)
echo $"Usage: $0 {generc|rpi}"
exit 1
esac