neko/server/build

36 lines
873 B
Plaintext
Raw Permalink Normal View History

2020-01-21 03:37:32 +13:00
#!/bin/bash
#
# aborting if any command returns a non-zero value
set -e
2020-04-19 13:12:49 +12:00
2020-01-13 21:05:38 +13:00
BUILD_TIME=`date -u +'%Y-%m-%dT%H:%M:%SZ'`
2023-03-18 08:47:53 +13:00
#
# set git build variables if git exists
if git status > /dev/null 2>&1 && [ -z $GIT_COMMIT ] && [ -z $GIT_BRANCH ] && [ -z $GIT_TAG ];
2023-03-18 08:47:53 +13:00
then
GIT_COMMIT=`git rev-parse --short HEAD`
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
GIT_TAG=`git tag --points-at $GIT_COMMIT | head -n 1`
2023-03-18 08:47:53 +13:00
GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "✗-"`
GIT_COMMIT="${GIT_DIRTY}${GIT_COMMIT}"
2023-03-18 08:47:53 +13:00
fi
#
# load dependencies
go get -v -t -d .
#
# build server
2023-03-18 08:47:53 +13:00
go build \
-o bin/neko \
-ldflags "
-s -w
-X 'm1k1o/neko.buildDate=${BUILD_TIME}'
-X 'm1k1o/neko.gitCommit=${GIT_COMMIT}'
2023-03-18 08:47:53 +13:00
-X 'm1k1o/neko.gitBranch=${GIT_BRANCH}'
-X 'm1k1o/neko.gitTag=${GIT_TAG}'
2023-03-18 08:47:53 +13:00
" \
cmd/neko/main.go;