-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·51 lines (43 loc) · 1.57 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
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
program_name="soc-cli"
# Determine the version
if [ -n "$1" ]; then
version=$1
else
# Get the short SHA of the current commit
short_sha=$(git rev-parse --short HEAD)
echo "No version specified, defaulting to dev-${short-sha}"
version="dev-${short_sha}"
fi
# Remove existing soc-cli_* files if they exist
echo ":: Removing existing ${program_name} files..."
rm build/${program_name}_*
# Build for Windows (64-bit)
echo ":: Building for Windows (64-bit)..."
GOOS=windows GOARCH=amd64 go build -ldflags "-X 'soc-cli/cmd.Version=${version}'" -o "build/${program_name}_${version}_windows_amd64.exe"
if [ $? -ne 0 ]; then
echo "Failed to build for Windows."
exit 1
fi
# Build for macOS (Intel)
echo ":: Building for macOS (Intel)..."
GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'soc-cli/cmd.Version=${version}'" -o "build/${program_name}_${version}_darwin_amd64"
if [ $? -ne 0 ]; then
echo "Failed to build for macOS (Intel)."
exit 1
fi
# Build for macOS (Apple Silicon)
echo ":: Building for macOS (Apple Silicon)..."
GOARCH=arm64 go build -ldflags "-X 'soc-cli/cmd.Version=${version}'" -o "build/${program_name}_${version}_darwin_arm64"
if [ $? -ne 0 ]; then
echo "Failed to build for macOS (Apple Silicon)."
exit 1
fi
# Build for Linux (64-bit)
echo ":: Building for Linux (64-bit)..."
GOOS=linux GOARCH=amd64 go build -ldflags "-X 'soc-cli/cmd.Version=${version}'" -o "build/${program_name}_${version}_linux_amd64"
if [ $? -ne 0 ]; then
echo "Failed to build for Linux (64-bit)."
exit 1
fi
echo "Build completed successfully!"