-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild
More file actions
executable file
·43 lines (39 loc) · 874 Bytes
/
build
File metadata and controls
executable file
·43 lines (39 loc) · 874 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
# Define target OS/arch combinations to build
BUILD_TARGETS=(
"linux/amd64"
"linux/arm"
"linux/arm64"
"linux/riscv64"
"windows/amd64"
"windows/arm64"
"darwin/amd64"
"darwin/arm64"
)
# Define targets that should be compressed with UPX
COMPRESS_TARGETS=(
"linux/amd64"
"linux/arm"
"linux/arm64"
"windows/amd64"
)
go-build(){
CGO_ENABLED=0 \
GOOS=$GOOS \
GOARCH=$GOARCH \
go build \
-o _dist/drycc-$1-$GOOS-$GOARCH \
drycc.go
# Check if current target is in COMPRESS_TARGETS list
target="$GOOS/$GOARCH"
if [[ ${COMPRESS_TARGETS[@]/$target/} != ${COMPRESS_TARGETS[@]} ]]; then
upx --lzma --best _dist/drycc-$1-$GOOS-$GOARCH
fi
}
# Process each target
for target in "${BUILD_TARGETS[@]}"; do
# Split target into OS and architecture
GOOS=${target%/*}
GOARCH=${target#*/}
go-build "$1"
done