-
-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·50 lines (39 loc) · 1.2 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·50 lines (39 loc) · 1.2 KB
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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUT_DIR="$ROOT_DIR/bin"
mkdir -p "$OUT_DIR"
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
LDFLAGS="-s -w -X 'main.version=${VERSION}' -X 'main.commit=${COMMIT}' -X 'main.date=${DATE}'"
platforms=(
"darwin amd64"
"darwin arm64"
"linux amd64"
"linux arm64"
"windows amd64"
"windows arm64"
)
for platform in "${platforms[@]}"; do
read -r goos goarch <<<"$platform"
case "$goos" in
darwin) goos_label="Darwin" ;;
linux) goos_label="Linux" ;;
windows) goos_label="Windows" ;;
*) goos_label="$goos" ;;
esac
case "$goarch" in
amd64) goarch_label="x86_64" ;;
arm64) goarch_label="arm64" ;;
*) goarch_label="$goarch" ;;
esac
output="$OUT_DIR/resterm_${goos_label}_${goarch_label}"
if [[ "$goos" == "windows" ]]; then
output+=".exe"
fi
echo "Building $output (version: $VERSION)"
GOOS="$goos" GOARCH="$goarch" go build -trimpath -ldflags "$LDFLAGS" -o "$output" ./cmd/resterm
done
echo ""
echo "Build complete! Version: $VERSION"