-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·39 lines (33 loc) · 907 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
#!/usr/bin/env bash
builddir=build
name=pg2sqlite
version=$(cat VERSION)
declare -a goos=( darwin darwin linux linux windows windows freebsd freebsd )
declare -a goarch=(amd64 arm64 amd64 arm64 amd64 arm amd64 arm )
# Compress: os file
compress () {
if [ "$1" == "windows" ]
then
zip -m "$2".zip "$2"
else
gzip "$2"
fi
}
if [ ! -d $builddir ]
then
echo "Creating build directory"
mkdir -p $builddir
else
echo "Cleaning build directory"
rm $builddir/*
fi
echo "Building pg2sqlite ..."
for K in "${!goos[@]}"; do
current_os=${goos[$K]}
current_arch=${goarch[$K]}
product="$name"_"$version"_$current_os-$current_arch
if [ "$current_os" == "windows" ]; then product=$product.exe; fi
echo Build "$K" : "$product"
env GOOS="$current_os" GOARCH="$current_arch" go build -o $builddir/"$product"
compress "$current_os" $builddir/"$product"
done