-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·30 lines (21 loc) · 1017 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
#!/usr/bin/env bash
# Build script to compile to multiple platforms and architectures
set -o errexit
set -o nounset
set -o pipefail
# Base name of the project
APP="cidls"
# version is the first argument passed to the script (in format n.n.n)
VERSION=$1
# Generate a build number as current date in the format YYYYMMDDhhmm
BUILD=$(date +"%Y%m%d%H%M")
# Setup the -ldflags option for go build, adding the version and build number
LDFLAGS="-X main.Version=${VERSION} -X main.Build=${BUILD}"
[ ! -d "build" ] && mkdir -p build
# Build for Darwin (MacOS) on both amd64 and arm64 architectures
GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o build/${APP}_darwin_amd64
GOOS=darwin GOARCH=arm64 go build -ldflags "$LDFLAGS" -o build/${APP}_darwin_arm64
# Build for Linux on both amd64 and arm64 architectures
GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o build/${APP}_linux_amd64
GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o build/${APP}_linux_arm64
echo -e "\n 🎉 Build complete \n"