-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
37 lines (26 loc) · 889 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
#!/bin/bash
GO="$(which go 2> /dev/null)";
ROOT="$(pwd)";
build() {
local go_os="${1}";
local go_arch="${2}";
if [[ ! -d "${ROOT}/build" ]]; then
mkdir -p "${ROOT}/build";
fi;
if [[ "${go_os}" == "windows" ]]; then
cd "${ROOT}/source";
env CGO_ENABLED=0 GOOS="${go_os}" GOARCH="${go_arch}" ${GO} build -ldflags "-s -w" -o "${ROOT}/build/pacman-backup-${go_os}_${go_arch}.exe" "${ROOT}/source/cmds/pacman-backup/main.go";
else
cd "${ROOT}/source";
env CGO_ENABLED=0 GOOS="${go_os}" GOARCH="${go_arch}" ${GO} build -ldflags "-s -w" -o "${ROOT}/build/pacman-backup-${go_os}_${go_arch}" "${ROOT}/source/cmds/pacman-backup/main.go";
fi;
if [[ $? == 0 ]]; then
echo -e "- Build ${go_os} / ${go_arch}: [\e[32mok\e[0m]";
return 1;
else
echo -e "- Build ${go_os} / ${go_arch}: [\e[31mfail\e[0m]";
return 0;
fi;
}
build "linux" "amd64";
build "linux" "arm64";