build-all.sh 2.4 KB

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