build-artifacts.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. --disable-dependency-tracking \
  32. CFLAGS=-O2
  33. make dist
  34. mv "${BASENAME}.tar.gz" artifacts/
  35. ) >&2
  36. }
  37. build_static_x86_64() {
  38. progress "Building static x86_64"
  39. (
  40. command -v git > /dev/null && [ -d .git ] && git clean -d -f
  41. USER="" ./packaging/makeself/build-x86_64-static.sh
  42. ) >&2
  43. }
  44. prepare_assets() {
  45. progress "Preparing assets"
  46. (
  47. cp packaging/version artifacts/latest-version.txt
  48. cd artifacts || exit 1
  49. ln -f "${BASENAME}.tar.gz" netdata-latest.tar.gz
  50. ln -f "${BASENAME}.gz.run" netdata-latest.gz.run
  51. sha256sum -b ./* > "sha256sums.txt"
  52. ) >&2
  53. }
  54. steps="prepare_build build_dist build_static_x86_64"
  55. steps="$steps prepare_assets"
  56. _main() {
  57. for step in $steps; do
  58. if ! run "$step"; then
  59. if [ -t 1 ]; then
  60. debug
  61. else
  62. fail "Build failed"
  63. fi
  64. fi
  65. done
  66. echo "🎉 All Done!"
  67. }
  68. if [ -n "$0" ] && [ x"$0" != x"-bash" ]; then
  69. _main "$@"
  70. fi