create_artifacts.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  2. #
  3. # Artifacts creation script.
  4. # This script generates two things:
  5. # 1) The static binary that can run on all linux distros (built-in dependencies etc)
  6. # 2) The distribution source tarbal
  7. #
  8. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  9. #
  10. # Author: Paul Emm. Katsoulakis <paul@netdata.cloud>
  11. #
  12. # shellcheck disable=SC2230
  13. set -e
  14. # If we are not in netdata git repo, at the top level directory, fail
  15. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  16. CWD=$(git rev-parse --show-cdup || echo "")
  17. if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  18. echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
  19. exit 1
  20. fi
  21. if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
  22. echo "Beta mode on ${TRAVIS_REPO_SLUG}, not running anything here"
  23. exit 0
  24. fi;
  25. echo "--- Initialize git configuration ---"
  26. git checkout "${1-master}"
  27. git pull
  28. if [ "${RELEASE_CHANNEL}" == stable ]; then
  29. echo "--- Set default release channel to stable ---"
  30. sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' \
  31. netdata-installer.sh \
  32. packaging/makeself/install-or-update.sh
  33. fi
  34. # Everything from this directory will be uploaded to GCS
  35. mkdir -p artifacts
  36. BASENAME="netdata-$(git describe)"
  37. # Make sure stdout is in blocking mode. If we don't, then conda create will barf during downloads.
  38. # See https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 for details.
  39. python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
  40. echo "--- Create tarball ---"
  41. autoreconf -ivf
  42. ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libexecdir=/usr/libexec --with-zlib --with-math --with-user=netdata CFLAGS=-O2
  43. make dist
  44. mv "${BASENAME}.tar.gz" artifacts/
  45. echo "--- Create self-extractor ---"
  46. ./packaging/makeself/build-x86_64-static.sh
  47. # Needed for GCS
  48. echo "--- Copy artifacts to separate directory ---"
  49. #shellcheck disable=SC2164
  50. cp packaging/version artifacts/latest-version.txt
  51. cd artifacts
  52. ln -s "${BASENAME}.tar.gz" netdata-latest.tar.gz
  53. ln -s "${BASENAME}.gz.run" netdata-latest.gz.run
  54. sha256sum -b ./* >"sha256sums.txt"
  55. echo "checksums:"
  56. cat sha256sums.txt