~louis77/pg2sqlite

ref: 5f7d541a5d13b0b4abe844cf2fc7e7eb8700a01c pg2sqlite/build.sh -rwxr-xr-x 907 bytes
5f7d541a — Louis Brauer Remove Surge upload from build.sh 3 months ago
                                                                                
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