-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·45 lines (35 loc) · 1006 Bytes
/
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
#!/usr/bin/env bash
OS_LIST=(darwin windows linux)
ARCH_LIST=(amd64 386)
PROJECT_NAME=${PWD##*/}
BUILD_FOLDER="dist"
# create temporary build folder
TMP=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
function compile_go_binary() {
local os=${1}
local arch=${2}
local output_filename="$PROJECT_NAME-$os-$arch"
if [ "$os" = "windows" ]; then
output_filename="${output_filename}.exe"
fi
GOOS=$os GOARCH=$arch go build -o "$TMP/$output_filename"
}
function prepare_static_folder() {
(
cd photoboxrecents-web
npm install && npm run build
)
mkdir "$TMP/photoboxrecents-web"
cp -rf photoboxrecents-web/dist "$TMP/photoboxrecents-web"
}
for os in "${OS_LIST[@]}"; do
for arch in "${ARCH_LIST[@]}"; do
echo "Compile $os-$arch"
compile_go_binary $os $arch
done
done
prepare_static_folder
cp start.bat $TMP
DATE=$(date +"%Y%m%d-%H%M%S")
(cd $TMP && zip -r - .) > "$BUILD_FOLDER/$PROJECT_NAME-$DATE.zip"
rm -rf $TMP