build-all.sh 2.1 KB

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