#!/bin/bash

# This script creates 64-bit release builds for OSX, Linux and Windows. It
# requires Go to be set up for cross-compiling to these platforms. Some package
# managers can set this up for you (homebrew can do this, for example). For
# instructions on how to set up cross-compiling manually, there's an excellent
# guide here:
# http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1.

set -e

release_dir=release
name=commitfmt
compress_cmd="zip -9 -m -T -D"

mkdir -p $release_dir

GOOS=darwin GOARCH=amd64 go build -o $release_dir/$name
pushd $release_dir
$compress_cmd $name-osx.zip $name
popd

GOOS=linux GOARCH=amd64 go build -o $release_dir/$name
pushd $release_dir
$compress_cmd $name-linux.zip $name
popd

GOOS=windows GOARCH=amd64 go build -o $release_dir/$name.exe
pushd $release_dir
$compress_cmd $name-windows.zip $name.exe
popd

#!/bin/sh

# This script creates 64-bit release builds for OSX, Linux and Windows. It
# requires Go to be set up for cross-compiling to these platforms. Some package
# managers can set this up for you (homebrew can do this, for example). For
# instructions on how to set up cross-compiling manually, there's an excellent
# guide here:
# http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1.

set -e

mkdir -p release

GOOS=darwin GOARCH=amd64 go build -o release/commitfmt
cd release
tar -czf commitfmt-macos.tar.gz commitfmt
rm commitfmt
cd ..

GOOS=linux GOARCH=amd64 go build -o release/commitfmt
cd release
tar -czf commitfmt-linux.tar.gz commitfmt
rm commitfmt
cd ..

GOOS=windows GOARCH=amd64 go build -o release/commitfmt.exe
cd release
zip -9 -m -T -D -q commitfmt-windows.zip commitfmt.exe
cd ..

Make release script more portable
Make release script more portable

Also use tar for compressing releases on linux and macOS.
