build-all.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. #
  3. # This script is executed from within the container.
  4. #
  5. set -e
  6. EXTRA_OPTS="$@"
  7. CCARMV7=arm-linux-gnueabihf-gcc
  8. CCARM64=aarch64-linux-gnu-gcc
  9. CCOSX64=/tmp/osxcross/target/bin/o64-clang
  10. CCWIN64=x86_64-w64-mingw32-gcc
  11. CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
  12. GOPATH=/go
  13. REPO_PATH=$GOPATH/src/github.com/grafana/grafana
  14. cd /go/src/github.com/grafana/grafana
  15. echo "current dir: $(pwd)"
  16. if [ "$CIRCLE_TAG" != "" ]; then
  17. echo "Building releases from tag $CIRCLE_TAG"
  18. OPT="-includeBuildNumber=false ${EXTRA_OPTS}"
  19. else
  20. echo "Building incremental build for $CIRCLE_BRANCH"
  21. OPT="-buildNumber=${CIRCLE_BUILD_NUM} ${EXTRA_OPTS}"
  22. fi
  23. echo "Build arguments: $OPT"
  24. go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
  25. go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
  26. # MacOS build is broken atm. See Issue #13763
  27. #go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build
  28. go run build.go -goos windows -cc ${CCWIN64} ${OPT} build
  29. CC=${CCX64} go run build.go ${OPT} build
  30. yarn install --pure-lockfile --no-progress
  31. echo "current dir: $(pwd)"
  32. if [ -d "dist" ]; then
  33. rm -rf dist
  34. fi
  35. if [ "$CIRCLE_TAG" != "" ]; then
  36. echo "Building frontend and packaging from tag $CIRCLE_TAG"
  37. else
  38. echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
  39. fi
  40. echo "Building frontend"
  41. go run build.go ${OPT} build-frontend
  42. # Load ruby, needed for packing with fpm
  43. source /etc/profile.d/rvm.sh
  44. echo "Packaging"
  45. go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only latest
  46. #removing amd64 phantomjs bin for armv7/arm64 packages
  47. rm tools/phantomjs/phantomjs
  48. go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only
  49. go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only
  50. if [ -d '/tmp/phantomjs/darwin' ]; then
  51. cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs
  52. else
  53. echo 'PhantomJS binaries for darwin missing!'
  54. fi
  55. go run build.go -goos darwin -pkg-arch amd64 ${OPT} package-only
  56. if [ -d '/tmp/phantomjs/windows' ]; then
  57. cp /tmp/phantomjs/windows/phantomjs.exe tools/phantomjs/phantomjs.exe
  58. rm tools/phantomjs/phantomjs
  59. else
  60. echo 'PhantomJS binaries for Windows missing!'
  61. fi
  62. go run build.go -goos windows -pkg-arch amd64 ${OPT} package-only