gohttpserver/build.sh

38 lines
778 B
Bash
Raw Permalink Normal View History

2016-07-28 10:30:39 +02:00
#!/bin/bash -
set -eu
2016-07-31 04:19:32 +02:00
VERSION=$(git describe --abbrev=0 --tags)
REVCNT=$(git rev-list --count HEAD)
DEVCNT=$(git rev-list --count $VERSION)
if test $REVCNT != $DEVCNT
then
2016-07-31 04:22:55 +02:00
VERSION="$VERSION.dev$(expr $REVCNT - $DEVCNT)"
2016-07-31 04:19:32 +02:00
fi
echo "VER: $VERSION"
2016-07-31 04:22:55 +02:00
GITCOMMIT=$(git rev-parse HEAD)
BUILDTIME=$(date -u +%Y/%m/%d-%H:%M:%S)
2016-08-01 09:34:41 +02:00
LDFLAGS="-X main.VERSION=$VERSION -X main.BUILDTIME=$BUILDTIME -X main.GITCOMMIT=$GITCOMMIT"
2016-08-04 03:46:24 +02:00
if [[ -n "${EX_LDFLAGS:-""}" ]]
2016-08-01 09:34:41 +02:00
then
LDFLAGS="$LDFLAGS $EX_LDFLAGS"
fi
2016-07-28 10:30:39 +02:00
build() {
echo "$1 $2 ..."
2016-07-31 04:19:32 +02:00
GOOS=$1 GOARCH=$2 go build \
2020-10-10 09:05:59 +02:00
-tags vfs \
2016-08-01 09:34:41 +02:00
-ldflags "$LDFLAGS" \
2016-07-31 04:19:32 +02:00
-o dist/gohttpserver-${3:-""}
2016-07-28 10:30:39 +02:00
}
2020-10-10 09:05:59 +02:00
go generate .
2016-07-28 10:30:39 +02:00
2016-08-03 16:57:45 +02:00
build linux arm linux-arm
2016-07-28 10:30:39 +02:00
build darwin amd64 mac-amd64
build linux amd64 linux-amd64
build linux 386 linux-386
build windows amd64 win-amd64.exe