create_artifacts.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 tarball
  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. command -v git > /dev/null && [ -d .git ] && git clean -d -f
  42. autoreconf -ivf
  43. ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libexecdir=/usr/libexec --with-zlib --with-math --with-user=netdata CFLAGS=-O2
  44. make dist
  45. mv "${BASENAME}.tar.gz" artifacts/
  46. echo "--- Create self-extractor ---"
  47. sxarches="x86_64 armv7l aarch64"
  48. for arch in ${sxarches}; do
  49. git clean -d -f
  50. rm -rf packating/makeself/tmp
  51. ./packaging/makeself/build-static.sh ${arch}
  52. done
  53. # Needed for GCS
  54. echo "--- Copy artifacts to separate directory ---"
  55. #shellcheck disable=SC2164
  56. cp packaging/version artifacts/latest-version.txt
  57. cd artifacts
  58. ln -s "${BASENAME}.tar.gz" netdata-latest.tar.gz
  59. for arch in ${sxarches}; do
  60. ln -s "netdata-${arch}-$(git describe).gz.run" netdata-${arch}-latest.gz.run
  61. done
  62. ln -s "${BASENAME}.gz.run" netdata-latest.gz.run
  63. sha256sum -b ./* > "sha256sums.txt"
  64. echo "checksums:"
  65. cat sha256sums.txt