build-dist.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. #
  3. # Builds the netdata-vX.y.Z-xxxx.tar.gz source tarball (dist)
  4. set -e
  5. # shellcheck source=.github/scripts/functions.sh
  6. . "$(dirname "$0")/functions.sh"
  7. NAME="${NAME:-netdata}"
  8. VERSION="${VERSION:-"$(git describe --always)"}"
  9. BASENAME="$NAME-$VERSION"
  10. prepare_build() {
  11. progress "Preparing build"
  12. (
  13. test -d artifacts || mkdir -p artifacts
  14. echo "${VERSION}" > packaging/version
  15. ) >&2
  16. }
  17. build_dist() {
  18. progress "Building dist"
  19. (
  20. command -v git > /dev/null && [ -d .git ] && git clean -d -f
  21. autoreconf -ivf
  22. ./configure \
  23. --prefix=/usr \
  24. --sysconfdir=/etc \
  25. --localstatedir=/var \
  26. --libexecdir=/usr/libexec \
  27. --with-zlib \
  28. --with-math \
  29. --with-user=netdata \
  30. CFLAGS=-O2
  31. make dist
  32. mv "${BASENAME}.tar.gz" artifacts/
  33. ) >&2
  34. }
  35. prepare_assets() {
  36. progress "Preparing assets"
  37. (
  38. cp packaging/version artifacts/latest-version.txt
  39. cd artifacts || exit 1
  40. ln -f "${BASENAME}.tar.gz" netdata-latest.tar.gz
  41. ln -f "${BASENAME}.gz.run" netdata-latest.gz.run
  42. sha256sum -b ./* > "sha256sums.txt"
  43. ) >&2
  44. }
  45. steps="prepare_build build_dist prepare_assets"
  46. _main() {
  47. for step in $steps; do
  48. if ! run "$step"; then
  49. if [ -t 1 ]; then
  50. debug
  51. else
  52. fail "Build failed"
  53. fi
  54. fi
  55. done
  56. echo "🎉 All Done!"
  57. }
  58. if [ -n "$0" ] && [ x"$0" != x"-bash" ]; then
  59. _main "$@"
  60. fi