build-all.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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="-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. # build only amd64 for enterprise
  25. if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
  26. go run build.go -goarch armv6 -cc ${CCARMV7} ${OPT} build
  27. go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
  28. go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
  29. go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build
  30. fi
  31. go run build.go -goos windows -cc ${CCWIN64} ${OPT} build
  32. # Do not remove CC from the linux build, its there for compatibility with Centos6
  33. CC=${CCX64} go run build.go ${OPT} build
  34. yarn install --pure-lockfile --no-progress
  35. echo "current dir: $(pwd)"
  36. if [ -d "dist" ]; then
  37. rm -rf dist
  38. fi
  39. if [ "$CIRCLE_TAG" != "" ]; then
  40. echo "Building frontend and packaging from tag $CIRCLE_TAG"
  41. else
  42. echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
  43. fi
  44. echo "Building frontend"
  45. go run build.go ${OPT} build-frontend
  46. # Load ruby, needed for packing with fpm
  47. source /etc/profile.d/rvm.sh
  48. echo "Packaging"
  49. go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only
  50. #removing amd64 phantomjs bin for armv7/arm64 packages
  51. rm tools/phantomjs/phantomjs
  52. # build only amd64 for enterprise
  53. if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
  54. go run build.go -goos linux -pkg-arch armv6 ${OPT} -skipRpm package-only
  55. go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only
  56. go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only
  57. if [ -d '/tmp/phantomjs/darwin' ]; then
  58. cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs
  59. else
  60. echo 'PhantomJS binaries for darwin missing!'
  61. fi
  62. go run build.go -goos darwin -pkg-arch amd64 ${OPT} package-only
  63. fi
  64. if [ -d '/tmp/phantomjs/windows' ]; then
  65. cp /tmp/phantomjs/windows/phantomjs.exe tools/phantomjs/phantomjs.exe
  66. rm tools/phantomjs/phantomjs || true
  67. else
  68. echo 'PhantomJS binaries for Windows missing!'
  69. fi
  70. go run build.go -goos windows -pkg-arch amd64 ${OPT} package-only
  71. go run build.go latest