forked from yorkie-team/yorkie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-binaries.sh
executable file
·57 lines (42 loc) · 1.12 KB
/
build-binaries.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
#!/usr/bin/env bash
set -e
YORKIE_VERSION=$1
GO_LDFLAGS=$2
if [ "$#" -ne 2 ]; then
echo "Usage: ${0} VERSION GO_LDFLAGS" >> /dev/stderr
exit 255
fi
set -u
function main {
mkdir -p binaries
cd binaries
for os in darwin windows linux; do
local ext=""
export GOOS=${os}
TARGET_ARCHS=("amd64")
if [ "${GOOS}" == "windows" ]; then
ext=".exe"
fi
if [ ${GOOS} == "linux" ]; then
TARGET_ARCHS+=("arm64")
TARGET_ARCHS+=("ppc64le")
fi
for TARGET_ARCH in "${TARGET_ARCHS[@]}"; do
export GOARCH=${TARGET_ARCH}
TARGET="yorkie-v${YORKIE_VERSION}-${GOOS}-${GOARCH}"
mkdir -p "${TARGET}"
CGO_ENABLED=0 go build -o "${TARGET}/yorkie${ext}" -ldflags "${GO_LDFLAGS}" ../cmd/yorkie
for FILE_NAME in README ROADMAP CHANGELOG ; do
cp "../${FILE_NAME}.md" "${TARGET}/${FILE_NAME}.md"
done
if [ ${GOOS} == "linux" ]; then
tar cfz "${TARGET}.tar.gz" "${TARGET}"
echo "Wrote binaries/${TARGET}.tar.gz"
else
zip -qr "${TARGET}.zip" "${TARGET}"
echo "Wrote binaries/${TARGET}.zip"
fi
done
done
}
main