mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
80 lines
1.6 KiB
Bash
Executable File
80 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# aborting if any command returns a non-zero value
|
|
set -e
|
|
|
|
#
|
|
# do not build plugins when passing "core" as first argument
|
|
if [ "$1" = "core" ];
|
|
then
|
|
skip_plugins="true"
|
|
fi
|
|
|
|
#
|
|
# set git build variables if git exists
|
|
if git version > /dev/null && [ -z $GIT_COMMIT ] && [ -z $GIT_BRANCH ] && [ -z $GIT_TAG ];
|
|
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`
|
|
fi
|
|
|
|
#
|
|
# load server dependencies
|
|
go get -v -t -d .
|
|
|
|
#
|
|
# build server
|
|
go build \
|
|
-o bin/neko \
|
|
-ldflags "
|
|
-s -w
|
|
-X 'gitlab.com/demodesk/neko/server.buildDate=`date -u +'%Y-%m-%dT%H:%M:%SZ'`'
|
|
-X 'gitlab.com/demodesk/neko/server.gitCommit=${GIT_COMMIT}'
|
|
-X 'gitlab.com/demodesk/neko/server.gitBranch=${GIT_BRANCH}'
|
|
-X 'gitlab.com/demodesk/neko/server.gitTag=${GIT_TAG}'
|
|
" \
|
|
cmd/neko/main.go;
|
|
|
|
#
|
|
# if plugins are ignored
|
|
if [ "$skip_plugins" = "true" ];
|
|
then
|
|
echo "Not building plugins..."
|
|
exit 0
|
|
fi
|
|
|
|
#
|
|
# if plugins directory does not exist
|
|
if [ ! -d "./plugins" ];
|
|
then
|
|
echo "No plugins directory found, skipping..."
|
|
exit 0
|
|
fi
|
|
|
|
#
|
|
# ensure plugins folder exits and remove old plugins
|
|
mkdir -p bin/plugins
|
|
rm -f bin/plugins/*
|
|
|
|
#
|
|
# build plugins
|
|
for plugPath in ./plugins/*; do
|
|
pushd $plugPath
|
|
|
|
echo "Building plugin: $plugPath"
|
|
|
|
if [ ! -f "go.plug.mod" ];
|
|
then
|
|
echo "go.plug.mod not found, skipping..."
|
|
popd
|
|
continue
|
|
fi
|
|
|
|
# build plugin
|
|
go build -modfile=go.plug.mod -buildmode=plugin -o "../../bin/plugins/${plugPath##*/}.so"
|
|
|
|
popd
|
|
done
|