build-all.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. #
  3. # This script is executed from within the container.
  4. #
  5. set -e
  6. EXTRA_OPTS="$@"
  7. CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
  8. CCARMV7=arm-linux-gnueabihf-gcc
  9. CCARM64=aarch64-linux-gnu-gcc
  10. CCOSX64=/tmp/osxcross/target/bin/o64-clang
  11. CCWIN64=x86_64-w64-mingw32-gcc
  12. CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
  13. GOPATH=/go
  14. REPO_PATH=$GOPATH/src/github.com/grafana/grafana
  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. if [ -d "dist" ]; then
  27. rm -rf dist
  28. fi
  29. mkdir dist
  30. go run build.go -gen-version ${OPT} > dist/grafana.version
  31. # build only amd64 for enterprise
  32. if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
  33. go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build
  34. go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
  35. go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
  36. go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build
  37. fi
  38. go run build.go -goos windows -cc ${CCWIN64} ${OPT} build
  39. # Do not remove CC from the linux build, its there for compatibility with Centos6
  40. CC=${CCX64} go run build.go ${OPT} build
  41. yarn install --pure-lockfile --no-progress
  42. if [ "$CIRCLE_TAG" != "" ]; then
  43. echo "Building frontend and packaging from tag $CIRCLE_TAG"
  44. else
  45. echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
  46. fi
  47. echo "Building frontend"
  48. go run build.go ${OPT} build-frontend
  49. # Load ruby, needed for packing with fpm
  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