-
Notifications
You must be signed in to change notification settings - Fork 7
/
linux_build_release.sh
47 lines (36 loc) · 1.17 KB
/
linux_build_release.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
43
44
45
46
47
#!/bin/bash
build_and_package() {
local goos=$1
local goarch=$2
local filename=$3
echo "Building for ${goos}/${goarch}..."
CGO_ENABLED=0 GOOS=${goos} GOARCH=${goarch} go build -ldflags "-w -s" -trimpath
if [ $? -ne 0 ]; then
echo "Build failed for ${goos}/${goarch}"
return 1
fi
echo "Creating zip package for ${goos}/${goarch}..."
zip -r "${filename}.zip" "${APP_NAME}" data/*
if [ $? -ne 0 ]; then
echo "Zip failed for ${goos}/${goarch}"
return 1
fi
rm -rf "${APP_NAME}"
echo "Clean up temporary files for ${goos}/${goarch}."
}
if ! command -v go > /dev/null; then
echo "Error: go command not found"
exit 1
fi
if ! command -v zip > /dev/null; then
echo "Error: zip command not found"
exit 1
fi
APP_NAME="hfinger"
DATA_DIR="data"
build_and_package "linux" "amd64" "${APP_NAME}_linux_amd64"
build_and_package "linux" "arm64" "${APP_NAME}_linux_arm64"
build_and_package "linux" "arm" "${APP_NAME}_linux_arm"
build_and_package "darwin" "amd64" "${APP_NAME}_darwin_amd64"
build_and_package "darwin" "arm64" "${APP_NAME}_darwin_arm64"
echo "All builds and packages are completed."