build-all.sh 2.8 KB

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