From 7ca346e9f03b7d9d1e49b2fc81c3b0729c695ea3 Mon Sep 17 00:00:00 2001 From: Leonard Gram Date: Fri, 18 May 2018 11:38:31 +0200 Subject: [PATCH] build: downloads and bundles phantomjs for darwin and windows. --- .circleci/config.yml | 9 +++++++++ scripts/build/build.sh | 26 ++++++++++++++++++++++++++ scripts/build/download-phantomjs.sh | 17 +++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100755 scripts/build/download-phantomjs.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b074688c97..e4b123073a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,6 +77,15 @@ jobs: - run: name: prepare build tools command: '/tmp/bootstrap.sh' + - restore_cache: + key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }} + - run: + name: download phantomjs binaries + command: './scripts/build/download-phantomjs.sh' + - save_cache: + key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }} + paths: + - /tmp/phantomjs - run: name: build and package grafana command: './scripts/build/build.sh' diff --git a/scripts/build/build.sh b/scripts/build/build.sh index ab021d57692..7c08d2c333c 100755 --- a/scripts/build/build.sh +++ b/scripts/build/build.sh @@ -47,7 +47,20 @@ if [ "$CIRCLE_TAG" != "" ]; then go run build.go -goos linux -pkg-arch amd64 -includeBuildNumber=false package-only latest go run build.go -goos linux -pkg-arch armv7 -includeBuildNumber=false package-only go run build.go -goos linux -pkg-arch arm64 -includeBuildNumber=false package-only + + if [ -d '/tmp/phantomjs/darwin' ]; then + cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs + else + echo 'PhantomJS binaries for darwin missing!' + fi go run build.go -goos darwin -pkg-arch amd64 -includeBuildNumber=false package-only + + if [ -d '/tmp/phantomjs/windows' ]; then + cp /tmp/phantomjs/windows/phantomjs.exe tools/phantomjs/phantomjs.exe + rm tools/phantomjs/phantomjs + else + echo 'PhantomJS binaries for darwin missing!' + fi go run build.go -goos windows -pkg-arch amd64 -includeBuildNumber=false package-only else echo "Building frontend for $CIRCLE_BRANCH" @@ -56,6 +69,19 @@ else go run build.go -goos linux -pkg-arch amd64 -buildNumber=${CIRCLE_BUILD_NUM} package-only latest go run build.go -goos linux -pkg-arch armv7 -buildNumber=${CIRCLE_BUILD_NUM} package-only go run build.go -goos linux -pkg-arch arm64 -buildNumber=${CIRCLE_BUILD_NUM} package-only + + if [ -d '/tmp/phantomjs/darwin' ]; then + cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs + else + echo 'PhantomJS binaries for darwin missing!' + fi go run build.go -goos darwin -pkg-arch amd64 -buildNumber=${CIRCLE_BUILD_NUM} package-only + + if [ -d '/tmp/phantomjs/windows' ]; then + cp /tmp/phantomjs/windows/phantomjs.exe tools/phantomjs/phantomjs.exe + rm tools/phantomjs/phantomjs + else + echo 'PhantomJS binaries for windows missing!' + fi go run build.go -goos windows -pkg-arch amd64 -buildNumber=${CIRCLE_BUILD_NUM} package-only fi diff --git a/scripts/build/download-phantomjs.sh b/scripts/build/download-phantomjs.sh new file mode 100755 index 00000000000..e346faf8765 --- /dev/null +++ b/scripts/build/download-phantomjs.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e + +if [ ! -d '/tmp/phantomjs' ]; then + _version="2.1.1" + + curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$_version-windows.zip > /tmp/phantomjs-win.zip + curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$_version-macosx.zip > /tmp/phantomjs-mac.zip + + cd /tmp + unzip /tmp/phantomjs-win.zip + unzip /tmp/phantomjs-mac.zip + + mkdir -p /tmp/phantomjs/windows /tmp/phantomjs/darwin + + cp /tmp/phantomjs-$_version-windows/bin/phantomjs.exe /tmp/phantomjs/windows/phantomjs.exe + cp /tmp/phantomjs-$_version-macosx/bin/phantomjs /tmp/phantomjs/darwin/phantomjs +fi