diff --git a/.gitignore b/.gitignore index 3fa4a88..c276dac 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.so *.dylib terrafile +output # Test binary, build with `go test -c` *.test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..58d1208 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +release: + ./scripts/binary-release.sh diff --git a/scripts/binary-release.sh b/scripts/binary-release.sh new file mode 100755 index 0000000..4eda0c3 --- /dev/null +++ b/scripts/binary-release.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# clean up +echo "-> running clean up...." +rm -rf output/* + +# install gox +if ! which gox > /dev/null; then + echo "-> installing gox..." + go get -u github.com/mitchellh/gox +fi + +# build +echo "-> building..." +gox \ +-os="linux" \ +-arch="amd64" \ +-output "output/{{.OS}}_{{.Arch}}/terrafile" \ +. + +# Zip and copy to the dist dir +echo "" +echo "Packaging..." +for PLATFORM in $(find ./output -mindepth 1 -maxdepth 1 -type d); do + OSARCH=$(basename ${PLATFORM}) + echo "--> ${OSARCH}" + + pushd $PLATFORM >/dev/null 2>&1 + zip ../terrafile_${OSARCH}.zip ./* +done