sentinel/scripts/build.sh

31 lines
919 B
Bash
Raw Normal View History

2021-03-04 08:04:05 +01:00
#!/bin/bash
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
cd ".."
DIR="$PWD"
echo "== Installing dependencies =="
go mod download
echo "== Checking dependencies =="
go mod verify
set -e
echo "== Compiling =="
2021-03-06 16:55:39 +01:00
export IMPORTPATH="github.com/lbryio/sentinel"
2021-03-04 08:04:05 +01:00
mkdir -p "$DIR/bin"
go generate -v
export VERSIONSHORT="${TRAVIS_COMMIT:-"$(git describe --tags --always --dirty)"}"
export VERSIONLONG="${TRAVIS_COMMIT:-"$(git describe --tags --always --dirty --long)"}"
export COMMITMSG="$(echo ${TRAVIS_COMMIT_MESSAGE:-"$(git show -s --format=%s)"} | tr -d '"' | head -n 1)"
2021-03-06 16:55:39 +01:00
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o "./bin/sentinel" -asmflags -trimpath="$DIR" -ldflags "-X ${IMPORTPATH}/meta.version=${VERSIONSHORT} -X \"${IMPORTPATH}/meta.commitMsg=${COMMITMSG}\""
2021-03-04 08:04:05 +01:00
echo "$(git describe --tags --always --dirty)" > ./bin/watcher.txt
2021-03-06 16:55:39 +01:00
chmod +x ./bin/sentinel
2021-03-04 08:04:05 +01:00
exit 0