build-all.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. #
  3. # This script is executed from within the container.
  4. #
  5. set -e
  6. # shellcheck disable=SC2124
  7. EXTRA_OPTS="$@"
  8. CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
  9. CCARMV7=arm-linux-gnueabihf-gcc
  10. CCARM64=aarch64-linux-gnu-gcc
  11. CCOSX64=/tmp/osxcross/target/bin/o64-clang
  12. CCWIN64=x86_64-w64-mingw32-gcc
  13. CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
  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="-includeBuildId=false ${EXTRA_OPTS}"
  19. else
  20. echo "Building incremental build for $CIRCLE_BRANCH"
  21. OPT="-buildId=${CIRCLE_WORKFLOW_ID} ${EXTRA_OPTS}"
  22. fi
  23. echo "Build arguments: $OPT"
  24. echo "current dir: $(pwd)"
  25. # build only amd64 for enterprise
  26. if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
  27. go run build.go -goarch armv6 -cc "${CCARMV6}" "${OPT}" build
  28. go run build.go -goarch armv7 -cc "${CCARMV7}" "${OPT}" build
  29. go run build.go -goarch arm64 -cc "${CCARM64}" "${OPT}" build
  30. go run build.go -goos darwin -cc "${CCOSX64}" "${OPT}" build
  31. fi
  32. go run build.go -goos windows -cc "${CCWIN64}" "${OPT}" build
  33. # Do not remove CC from the linux build, its there for compatibility with Centos6
  34. CC=${CCX64} go run build.go "${OPT}" build
  35. yarn install --pure-lockfile --no-progress
  36. if [ "$CIRCLE_TAG" != "" ]; then
  37. echo "Building frontend and packaging from tag $CIRCLE_TAG"
  38. else
  39. echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
  40. fi
  41. echo "Building frontend"
  42. go run build.go "${OPT}" build-frontend
  43. if [ -d "dist" ]; then
  44. rm -rf dist
  45. fi
  46. mkdir dist
  47. go run build.go -gen-version "${OPT}" > dist/grafana.version
  48. # Load ruby, needed for packing with fpm
  49. # shellcheck disable=SC1091
  50. source /etc/profile.d/rvm.sh
  51. echo "Packaging"
  52. go run build.go -goos linux -pkg-arch amd64 "${OPT}" package-only
  53. #removing amd64 phantomjs bin for armv7/arm64 packages
  54. rm tools/phantomjs/phantomjs
  55. # build only amd64 for enterprise
  56. if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
  57. go run build.go -goos linux -pkg-arch armv6 "${OPT}" -skipRpm package-only
  58. go run build.go -goos linux -pkg-arch armv7 "${OPT}" package-only
  59. go run build.go -goos linux -pkg-arch arm64 "${OPT}" package-only
  60. if [ -d '/tmp/phantomjs/darwin' ]; then
  61. cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs
  62. else
  63. echo 'PhantomJS binaries for darwin missing!'
  64. fi
  65. go run build.go -goos darwin -pkg-arch amd64 "${OPT}" package-only
  66. fi
  67. if [ -d '/tmp/phantomjs/windows' ]; then
  68. cp /tmp/phantomjs/windows/phantomjs.exe tools/phantomjs/phantomjs.exe
  69. rm tools/phantomjs/phantomjs || true
  70. else
  71. echo 'PhantomJS binaries for Windows missing!'
  72. fi
  73. go run build.go -goos windows -pkg-arch amd64 "${OPT}" package-only
  74. go run build.go latest