Skip to content
This repository has been archived by the owner on Jun 14, 2019. It is now read-only.

Commit

Permalink
Build script to build, sign, & sum cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
calebhearth committed Mar 8, 2016
1 parent 4e7c94c commit 1b8a9ca
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

# support functions for go cross compilation

type setopt >/dev/null 2>&1 && setopt shwordsplit
PLATFORMS="darwin/386 darwin/amd64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm windows/386 windows/amd64 openbsd/386 openbsd/amd64"

function go-build-all {
rm dist/ftree-*
local FAILURES=""
for PLATFORM in $PLATFORMS; do
local GOOS=${PLATFORM%/*}
local GOARCH=${PLATFORM#*/}
local SRCFILENAME=`echo $@ | sed 's/\.go//'`
local CURDIRNAME=${PWD##*/}
local OUTPUT="${SRCFILENAME:-$CURDIRNAME}-${GOOS}-${GOARCH}" # if no src file given, use current dir name
local CMD="env GOOS=$GOOS GOARCH=$GOARCH go build -o dist/$OUTPUT"
echo "$CMD"
$CMD || (FAILURES="$FAILURES $PLATFORM" && continue)
local SIGN="gpg2 --detach-sign dist/$OUTPUT"
echo "$SIGN"
$SIGN || (FAILURES="$FAILURES gpg:$PLATFORM" && continue)
local SUM="shasum --algorithm=256 $OUTPUT"
echo "$SUM"
$( cd dist/ && $SUM > $OUTPUT.sha256 || (FAILURES="$FAILURES sha:$PLATFORM" && continue))
done
if [ "$FAILURES" != "" ]; then
echo "*** go-build-all FAILED on $FAILURES ***"
return 1
fi
}

go-build-all

0 comments on commit 1b8a9ca

Please sign in to comment.