forked from yusufcanb/tlm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
44 lines (34 loc) · 969 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Function to perform builds
build() {
os=$1
app_name=$2
version=$3
arch=$4
sha1=$(git rev-parse --short HEAD | tr -d '\n')
# Determine output filename with optional .exe extension
output_name="${app_name}_${version}_${os}_${arch}"
if [[ "$os" == "windows" ]]; then
output_name="${output_name}.exe"
fi
echo "Building for $os/$arch (version: $version) -> $output_name"
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -o "dist/${version}/${output_name}" -ldflags "-X main.sha1ver=$sha1" main.go
}
# Operating systems to target
targets=("darwin" "linux" "windows")
app_name="tlm"
if [ $# -eq 0 ]; then
echo "Error: Please provide a version number as a command-line argument."
exit 1
fi
version=$1
# Clear old build artifacts
rm -rf dist
# Create the output directory
mkdir dist
# Build for each OS
for os in "${targets[@]}"; do
build $os $app_name $version "arm64"
build $os $app_name $version "amd64"
done
echo "Done!"