Skip to content

Commit

Permalink
packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Oct 19, 2016
1 parent 9d5e8bc commit dd5ce60
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ install: all
@cp jsoned /usr/local/bin
uninstall:
@rm -f /usr/local/bin/jsoned

package:
@NOCOPY=1 ./build.sh package
33 changes: 32 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash
set -e

VERSION="0.0.1"
VERSION="0.1.0"
PROTECTED_MODE="no"

export GO15VENDOREXPERIMENT=1

cd $(dirname "${BASH_SOURCE[0]}")
OD="$(pwd)"
WD=$OD

# temp directory for storing isolated environment.
TMP="$(mktemp -d -t sdb.XXXX)"
Expand All @@ -30,6 +31,36 @@ if [ "$NOCOPY" != "1" ]; then
cd $WD
fi

package(){
echo Packaging $1 Binary
bdir=jsoned-${VERSION}-$2-$3
rm -rf packages/$bdir && mkdir -p packages/$bdir
GOOS=$2 GOARCH=$3 ./build.sh
if [ "$2" == "windows" ]; then
mv jsoned packages/$bdir/jsoned.exe
else
mv jsoned packages/$bdir
fi
cp README.md packages/$bdir
cd packages
if [ "$2" == "linux" ]; then
tar -zcf $bdir.tar.gz $bdir
else
zip -r -q $bdir.zip $bdir
fi
rm -rf $bdir
cd ..
}

if [ "$1" == "package" ]; then
rm -rf packages/
package "Windows" "windows" "amd64"
package "Mac" "darwin" "amd64"
package "Linux" "linux" "amd64"
package "FreeBSD" "freebsd" "amd64"
exit
fi

# build and store objects into original directory.
go build -ldflags "-X main.version=$VERSION" -o "$OD/jsoned" cmd/jsoned/*.go

0 comments on commit dd5ce60

Please sign in to comment.