forked from YouROK/torrent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·47 lines (39 loc) · 882 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
46
47
#!/usr/local/bin/bash
PLATFORMS=(
# 'linux/arm64'
# 'linux/arm7'
# 'linux/amd64'
# 'linux/arm5'
# 'linux/386'
# 'windows/amd64'
# 'windows/386'
# 'darwin/amd64'
# 'darwin/arm64'
# 'freebsd/amd64'
# 'linux/mips'
# 'linux/mipsle'
# 'linux/mips64'
# 'linux/mips64le'
)
type setopt >/dev/null 2>&1
GOBIN="go"
$GOBIN version
LDFLAGS="'-s -w'"
FAILURES=""
ROOT=${PWD}
OUTPUT="${ROOT}/dist"
#### Build server
echo "Build server"
cd "${ROOT}" || exit 1
$GOBIN mod tidy
$GOBIN mod download
BUILD_FLAGS="-ldflags=${LDFLAGS}"
for PLATFORM in "${PLATFORMS[@]}"; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
CMD="GOOS=${GOOS} GOARCH=${GOARCH} ${GOBIN} build ${BUILD_FLAGS} -o ${BIN_FILENAME} ."
echo "${CMD}"
eval "$CMD"
done