build-artifacts.sh 1.7 KB

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