-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·42 lines (32 loc) · 1.17 KB
/
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
#!/bin/bash
set -eux
goreleaser_snapshot_build() {
goreleaser release --snapshot --clean
}
manual_build() {
NAME=speedwagon
PLATFORMS=(linux windows)
ARCHS=(amd64 arm64)
BUILD_DIR=build
version=$(go run main.go version)
rm -rf "${BUILD_DIR}" && mkdir "${BUILD_DIR}"
for platform in "${PLATFORMS[@]}"; do
for goarch in "${ARCHS[@]}"; do
exe_name="${NAME}-${version}-${platform}-${goarch}"
# Windows should have an .exe at the end
if [[ "${platform}" = "windows" ]]; then
exe_name="${exe_name}.exe"
fi
GOARCH="${goarch}" GOOS="${platform}" go build -o "${BUILD_DIR}/${exe_name}"
done
done
# macOS should be a universal binary, so we just handle it separately
platform=darwin
exe_name="${NAME}-${version}-${platform}-universal"
for goarch in arm64 amd64; do
GOARCH="${goarch}" go build -o "${BUILD_DIR}/${NAME}_${goarch}"
done
lipo -create -output "${BUILD_DIR}/${exe_name}" "${BUILD_DIR}/${NAME}_arm64" "${BUILD_DIR}/${NAME}_amd64"
rm -f "${BUILD_DIR}/${NAME}_arm64" "${BUILD_DIR}/${NAME}_amd64"
}
goreleaser_snapshot_build