-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·76 lines (60 loc) · 1.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
#!/bin/bash
now=`date +%Y%m%d%H%M%S`
start=`date +%s`
version=$1
if [ "$1" == "" ]; then
echo "Version not found, perform snapshot build"
version=$now
fi
if [ ! -d ../build ]; then
mkdir ../build
fi
dir=$PWD
export buildDir=$(cd ../build; pwd)
targetDirName=warlock-$version
targetDir=$buildDir/warlock/$targetDirName
targetFile=warlock-$version.tar.gz
npm run clean
rm -rf run
rm -rf $targetDir
mkdir -p $targetDir
echo "build warlock..."
npm run build
if [ "$?" != "0" ]; then
echo "build warlock failed"
exit -1
fi
echo "mkdir..."
if [ ! -d $buildDir ]; then
mkdir $buildDir
fi
if [ ! -d $targetDir ]; then
mkdir $targetDir
fi
echo "cp..."
cp -r app $targetDir
cp -r config $targetDir
cp -r images $targetDir
cp -r public $targetDir
cp package.json $targetDir
cp package-lock.json $targetDir
cp prod.sh $targetDir
echo $version > $targetDir/Version
echo "npm i --production..."
cd $buildDir/warlock/$targetDirName
npm i --production
if [ "$?" != "0" ]; then
echo "easy build prod failed"
exit -1
fi
echo "tar..."
cd $buildDir/warlock
tar -zcvf $targetFile $targetDirName &>/dev/null
cd $dir
echo "clean..."
rm -rf $buildDir/warlock/$targetDirName
echo "build done"
echo $version
end=`date +%s`
dif=$[ end - start ]
echo "this shell script execution duration: $dif s"