-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·43 lines (33 loc) · 966 Bytes
/
build.sh
File metadata and controls
executable file
·43 lines (33 loc) · 966 Bytes
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
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
readonly ROOTDIR
# shellcheck source=SCRIPTDIR/.util/tools.sh
source "${ROOTDIR}/scripts/.util/tools.sh"
function main() {
util::tools::jq::install --directory "${ROOTDIR}/.bin"
IFS=" " read -r -a oses <<< "$(jq -r -S '.oses[]' "${ROOTDIR}/config.json" | xargs)"
mapfile -t binaries < <(find "${ROOTDIR}/src" -mindepth 2 -name cli -type d)
for os in "${oses[@]}"; do
for path in "${binaries[@]}"; do
local name output
name="$(basename "$(dirname "${path}")")"
output="${ROOTDIR}/bin/${name}"
if [[ "${os}" == "windows" ]]; then
output="${output}.exe"
fi
rm -f "${output}"
CGO_ENABLED=0 \
GOOS="${os}" \
GOARCH=amd64 \
go build \
-mod vendor \
-ldflags="-s -w" \
-o "${output}" \
"${path}"
done
done
}
main "${@:-}"