there we go
This commit is contained in:
44
build.sh
Normal file
44
build.sh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user