-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathbk-build.sh
executable file
·44 lines (33 loc) · 1.04 KB
/
bk-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# Build back-end Jetstream
# Use tmp folder as our GOPATH for the build
DEV=${STRATOS_BACKEND_DEV:-false}
ACTION=${1:-build}
NO_DEP=${STRATOS_USE_VENDOR_AS_IS:-false}
VERSION=${stratos_version:-dev}
set -euo pipefail
# Script folder
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
STRATOS="`cd "${DIR}/..";pwd`"
pushd "${STRATOS}" > /dev/null
# Determine the build version from the package file if not already set
if [ "${VERSION}" == "dev" ]; then
PACKAGE_VERSION=$(cat package.json | grep "version")
REGEX="\"version\": \"([0-9\.]*)\""
if [[ $PACKAGE_VERSION =~ $REGEX ]]; then
VERSION=${BASH_REMATCH[1]}
fi
fi
# Build backend or run tests
pushd "${STRATOS}/src/jetstream" > /dev/null
if [ "${ACTION}" == "build" ]; then
echo "Building backend ..."
echo "Building version: ${VERSION}"
GO111MODULE=on go build -ldflags -X=main.appVersion=${VERSION}
echo "Build complete ..."
else
echo "Running backend tests ..."
GO111MODULE=on go test ./... -v -count=1
fi
popd > /dev/null
popd > /dev/null