2018-05-21 07:06:01 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-07-24 07:54:48 -05:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
2019-11-08 05:48:32 -06:00
|
|
|
# shellcheck source=./scripts/helpers/exit-if-fail.sh
|
|
|
|
source "$(dirname "$0")/../helpers/exit-if-fail.sh"
|
2018-05-21 07:06:01 -05:00
|
|
|
#
|
|
|
|
# This script is executed from within the container.
|
|
|
|
#
|
|
|
|
|
2018-10-22 07:33:19 -05:00
|
|
|
set -e
|
|
|
|
|
2019-07-23 05:12:33 -05:00
|
|
|
# shellcheck disable=SC2124
|
2018-10-22 07:33:19 -05:00
|
|
|
EXTRA_OPTS="$@"
|
|
|
|
|
2019-03-22 10:12:42 -05:00
|
|
|
CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
|
2018-05-21 07:06:01 -05:00
|
|
|
CCARMV7=arm-linux-gnueabihf-gcc
|
2019-10-24 07:34:14 -05:00
|
|
|
CCARMV7_MUSL=/tmp/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-gcc
|
2018-05-21 07:06:01 -05:00
|
|
|
CCARM64=aarch64-linux-gnu-gcc
|
2019-10-24 07:34:14 -05:00
|
|
|
CCARM64_MUSL=/tmp/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
|
2018-05-21 07:06:01 -05:00
|
|
|
CCOSX64=/tmp/osxcross/target/bin/o64-clang
|
|
|
|
CCWIN64=x86_64-w64-mingw32-gcc
|
|
|
|
CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
|
2019-10-24 07:34:14 -05:00
|
|
|
CCX64_MUSL=/tmp/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc
|
2018-05-21 07:06:01 -05:00
|
|
|
|
|
|
|
cd /go/src/github.com/grafana/grafana
|
|
|
|
echo "current dir: $(pwd)"
|
|
|
|
|
2019-11-08 05:48:32 -06:00
|
|
|
function reportFrontEndBuildTime() {
|
|
|
|
if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
|
|
|
|
# Only report for build job
|
|
|
|
# build-enterprise happens right after build on master
|
|
|
|
# so there is no need for reporting the same metric again
|
|
|
|
exit_if_fail ./scripts/ci-metrics-publisher.sh "grafana.ci-performance.frontend-build=$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-21 07:06:01 -05:00
|
|
|
if [ "$CIRCLE_TAG" != "" ]; then
|
|
|
|
echo "Building releases from tag $CIRCLE_TAG"
|
2018-11-05 08:05:12 -06:00
|
|
|
OPT="-includeBuildId=false ${EXTRA_OPTS}"
|
2018-05-21 07:06:01 -05:00
|
|
|
else
|
|
|
|
echo "Building incremental build for $CIRCLE_BRANCH"
|
2018-11-05 08:05:12 -06:00
|
|
|
OPT="-buildId=${CIRCLE_WORKFLOW_ID} ${EXTRA_OPTS}"
|
2018-05-21 07:06:01 -05:00
|
|
|
fi
|
|
|
|
|
2018-10-22 07:33:19 -05:00
|
|
|
echo "Build arguments: $OPT"
|
2019-03-22 10:12:42 -05:00
|
|
|
echo "current dir: $(pwd)"
|
|
|
|
|
2019-11-21 02:41:32 -06:00
|
|
|
go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build
|
|
|
|
go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
|
|
|
|
go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
|
|
|
|
go run build.go -goarch armv7 -libc musl -cc ${CCARMV7_MUSL} ${OPT} build
|
|
|
|
go run build.go -goarch arm64 -libc musl -cc ${CCARM64_MUSL} ${OPT} build
|
|
|
|
go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build
|
|
|
|
|
2019-01-11 08:55:22 -06:00
|
|
|
|
2019-07-24 07:54:48 -05:00
|
|
|
go run build.go -goos windows -cc ${CCWIN64} ${OPT} build
|
2018-11-27 09:55:59 -06:00
|
|
|
|
|
|
|
# Do not remove CC from the linux build, its there for compatibility with Centos6
|
2019-10-24 07:34:14 -05:00
|
|
|
go run build.go -cc ${CCX64} ${OPT} build
|
|
|
|
|
|
|
|
go run build.go -cc ${CCX64_MUSL} -libc musl ${OPT} build
|
2018-05-23 16:53:59 -05:00
|
|
|
|
2018-05-21 07:06:01 -05:00
|
|
|
yarn install --pure-lockfile --no-progress
|
|
|
|
|
|
|
|
if [ "$CIRCLE_TAG" != "" ]; then
|
2018-05-23 16:53:59 -05:00
|
|
|
echo "Building frontend and packaging from tag $CIRCLE_TAG"
|
|
|
|
else
|
|
|
|
echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
|
|
|
|
fi
|
|
|
|
echo "Building frontend"
|
2019-11-08 05:48:32 -06:00
|
|
|
start=$(date +%s%N)
|
2019-07-24 07:54:48 -05:00
|
|
|
go run build.go ${OPT} build-frontend
|
2019-11-08 05:48:32 -06:00
|
|
|
runtime=$((($(date +%s%N) - start)/1000000))
|
|
|
|
echo "Frontent build took $runtime"
|
|
|
|
reportFrontEndBuildTime $runtime
|
2018-09-05 04:55:28 -05:00
|
|
|
|
2019-03-25 07:57:30 -05:00
|
|
|
if [ -d "dist" ]; then
|
|
|
|
rm -rf dist
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir dist
|
2019-07-24 07:54:48 -05:00
|
|
|
go run build.go -gen-version ${OPT} > dist/grafana.version
|
2019-03-25 07:57:30 -05:00
|
|
|
|
2018-09-05 04:55:28 -05:00
|
|
|
# Load ruby, needed for packing with fpm
|
2019-07-23 05:12:33 -05:00
|
|
|
# shellcheck disable=SC1091
|
2018-09-05 04:55:28 -05:00
|
|
|
source /etc/profile.d/rvm.sh
|
|
|
|
|
2018-05-23 16:53:59 -05:00
|
|
|
echo "Packaging"
|
2019-07-24 07:54:48 -05:00
|
|
|
go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only
|
2019-10-24 07:34:14 -05:00
|
|
|
go run build.go -goos linux -pkg-arch amd64 -libc musl ${OPT} -skipRpm -skipDeb package-only
|
2018-05-23 16:53:59 -05:00
|
|
|
#removing amd64 phantomjs bin for armv7/arm64 packages
|
|
|
|
rm tools/phantomjs/phantomjs
|
2018-05-21 07:06:01 -05:00
|
|
|
|
2019-01-17 09:42:27 -06:00
|
|
|
# build only amd64 for enterprise
|
2019-01-17 04:00:34 -06:00
|
|
|
if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
|
2019-07-24 07:54:48 -05:00
|
|
|
go run build.go -goos linux -pkg-arch armv6 ${OPT} -skipRpm package-only
|
|
|
|
go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only
|
|
|
|
go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only
|
2019-10-24 07:34:14 -05:00
|
|
|
go run build.go -goos linux -pkg-arch armv7 -libc musl ${OPT} -skipRpm -skipDeb package-only
|
|
|
|
go run build.go -goos linux -pkg-arch arm64 -libc musl ${OPT} -skipRpm -skipDeb package-only
|
2019-01-17 04:00:34 -06:00
|
|
|
|
|
|
|
if [ -d '/tmp/phantomjs/darwin' ]; then
|
|
|
|
cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs
|
|
|
|
else
|
|
|
|
echo 'PhantomJS binaries for darwin missing!'
|
|
|
|
fi
|
2019-07-24 07:54:48 -05:00
|
|
|
go run build.go -goos darwin -pkg-arch amd64 ${OPT} package-only
|
2018-05-23 16:53:59 -05:00
|
|
|
fi
|
2018-05-21 07:06:01 -05:00
|
|
|
|
2018-05-23 16:53:59 -05:00
|
|
|
if [ -d '/tmp/phantomjs/windows' ]; then
|
|
|
|
cp /tmp/phantomjs/windows/phantomjs.exe tools/phantomjs/phantomjs.exe
|
2019-01-17 04:00:34 -06:00
|
|
|
rm tools/phantomjs/phantomjs || true
|
2018-05-23 16:53:59 -05:00
|
|
|
else
|
2018-10-25 09:55:27 -05:00
|
|
|
echo 'PhantomJS binaries for Windows missing!'
|
2018-05-21 07:06:01 -05:00
|
|
|
fi
|
2019-12-10 09:00:37 -06:00
|
|
|
|
|
|
|
cp /usr/local/go/lib/time/zoneinfo.zip tools/zoneinfo.zip
|
2019-07-24 07:54:48 -05:00
|
|
|
go run build.go -goos windows -pkg-arch amd64 ${OPT} package-only
|
2019-12-10 09:00:37 -06:00
|
|
|
rm tools/zoneinfo.zip
|
2018-05-23 16:53:59 -05:00
|
|
|
|
2019-01-17 04:00:34 -06:00
|
|
|
go run build.go latest
|