#!/usr/bin/env bash

set -e

echo "Building binaries for various platforms"

# Create directory to store all binaries
binsdir=/tmp/mgbins
mkdir -p $binsdir
echo "Output directory for binaries created: $binsdir"

# Platforms (OS/arch matrix)
platforms="linux/amd64 darwin/amd64 windows/amd64"

# Build binaries for all listed platforms
for p in $platforms; do
  os=${p%/*}
  arc=${p#*/}
  echo "Building binary for platform: $p"
  fn=$binsdir/memgator-$os-$arc
  if [ $os == "windows" ]; then
    GOOS=$os GOARCH=$arc go build -v -o $fn.exe
  else
    GOOS=$os GOARCH=$arc CGO_ENABLED=0 go build -v -a -installsuffix cgo -o $fn
  fi
done

echo "Following binaries have been created in: $binsdir"
ls -lh $binsdir

#!/usr/bin/env bash

set -e

echo "Building binaries for various platforms"

# Create directory to store all binaries
binsdir=/tmp/mgbins
mkdir -p $binsdir
echo "Output directory for binaries created: $binsdir"

# OS and architecture matrix
oses="linux darwin windows"
arcs="386 amd64"

# Build binaries for all OSes and architectures
for os in $oses; do
  for arc in $arcs; do
    echo "Building binary for $os/$arc"
    fn=$binsdir/memgator-$os-$arc
    if [ $os == "windows" ]; then
      GOOS=$os GOARCH=$arc go build -v -o $fn.exe
    else
      GOOS=$os GOARCH=$arc CGO_ENABLED=0 go build -v -a -installsuffix cgo -o $fn || {
        echo "Failed to build $os/$arc"
      }
    fi
  done
done

echo "Following binaries have been created in: $binsdir"
ls -lh $binsdir

--- 
+++ 
@@ -9,23 +9,20 @@
 mkdir -p $binsdir
 echo "Output directory for binaries created: $binsdir"
 
-# OS and architecture matrix
-oses="linux darwin windows"
-arcs="386 amd64"
+# Platforms (OS/arch matrix)
+platforms="linux/amd64 darwin/amd64 windows/amd64"
 
-# Build binaries for all OSes and architectures
-for os in $oses; do
-  for arc in $arcs; do
-    echo "Building binary for $os/$arc"
-    fn=$binsdir/memgator-$os-$arc
-    if [ $os == "windows" ]; then
-      GOOS=$os GOARCH=$arc go build -v -o $fn.exe
-    else
-      GOOS=$os GOARCH=$arc CGO_ENABLED=0 go build -v -a -installsuffix cgo -o $fn || {
-        echo "Failed to build $os/$arc"
-      }
-    fi
-  done
+# Build binaries for all listed platforms
+for p in $platforms; do
+  os=${p%/*}
+  arc=${p#*/}
+  echo "Building binary for platform: $p"
+  fn=$binsdir/memgator-$os-$arc
+  if [ $os == "windows" ]; then
+    GOOS=$os GOARCH=$arc go build -v -o $fn.exe
+  else
+    GOOS=$os GOARCH=$arc CGO_ENABLED=0 go build -v -a -installsuffix cgo -o $fn
+  fi
 done
 
 echo "Following binaries have been created in: $binsdir"
Change build platforms listing style to OS/arch
