From 7cca58f5247cdf1bb6b463efd938e25aa711e41e Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Tue, 16 Jul 2019 07:21:49 -0600 Subject: [PATCH] there we go --- .gitignore | 4 ++++ build.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d3c2ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.tar +simpleserve +*.sw* +**.sw* diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..8ab411b --- /dev/null +++ b/build.sh @@ -0,0 +1,44 @@ +#! /bin/bash + +ss=simpleserve + +function main() { + init + server + local name="$(gitname)" + pack "$name" +} + +function init() { + set -e + cd "$(dirname "$BASH_SOURCE")" +} + +function server() { + pushd "$GOPATH/src/local/$ss" + local f="$(gobuild)" + popd + mv "$f" "./$ss" +} + +function gobuild() { + GOOS=linux CGO_ENABLED=0 go build -o /tmp/${PWD##*/} -a -installsuffix cgo >&2 + echo "/tmp/${PWD##*/}" +} + +function gitname() { + local name="$(git describe --tags)" + if [ -z "$name" ]; then + name="$(git rev-parse --abbrev-ref HEAD)" + fi + echo "$name" +} + +function pack() { + tar -czf "$1.tar" "$ss" "public" + echo "$1.tar" +} + +if [ "$0" == "${BASH_SOURCE[0]}" ]; then + main "$@" +fi