build-all.sh 2.2 KB

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