fix build.

This commit is contained in:
Miroslav Šedivý 2023-03-17 20:47:53 +01:00
parent d9403d9c14
commit 0cebe465a2
2 changed files with 24 additions and 6 deletions

View File

@ -17,5 +17,9 @@ fi
docker run --rm -it \ docker run --rm -it \
-v "${PWD}/../server:/src" \ -v "${PWD}/../server:/src" \
--entrypoint="go" \ -e GIT_COMMIT=`git rev-parse --short HEAD` \
neko_dev_server build -o "bin/neko" "cmd/neko/main.go" -e GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD` \
-e GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "✗-"` \
--entrypoint="bash" \
--workdir="/src" \
neko_dev_server ./build

View File

@ -3,8 +3,22 @@
set -ex set -ex
BUILD_TIME=`date -u +'%Y-%m-%dT%H:%M:%SZ'` BUILD_TIME=`date -u +'%Y-%m-%dT%H:%M:%SZ'`
GIT_COMMIT=`git rev-parse --short HEAD`
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "✗-"`
go build -o bin/neko -ldflags "-s -X 'm1k1o/neko.buildDate=${BUILD_TIME}' -X 'm1k1o/neko.gitCommit=${GIT_DIRTY}${GIT_COMMIT}' -X 'm1k1o/neko.gitBranch=${GIT_BRANCH}'" -i cmd/neko/main.go #
# set git build variables if git exists
if git status > /dev/null 2>&1 && [ -z $GIT_COMMIT ] && [ -z $GIT_BRANCH ] && [ -z $GIT_DIRTY ];
then
GIT_COMMIT=`git rev-parse --short HEAD`
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "✗-"`
fi
go build \
-o bin/neko \
-ldflags "
-s -w
-X 'm1k1o/neko.buildDate=${BUILD_TIME}'
-X 'm1k1o/neko.gitCommit=${GIT_DIRTY}${GIT_COMMIT}'
-X 'm1k1o/neko.gitBranch=${GIT_BRANCH}'
" \
cmd/neko/main.go;