create_artifacts.sh 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. # if nightlies.sh has not written this TRAVIS_BUILD_NUMBER, there's no
  26. # changes from last nigthly
  27. if [ -f .travis/current_build_status ]; then
  28. FILE_TRAVIS_BUILD_NUMBER=$(cut -d'#' -f2 < .travis/current_build_status)
  29. FILE_TRAVIS_BUILD_STATUS=$(cut -d- -f1 < .travis/current_build_status)
  30. if [[ ${FILE_TRAVIS_BUILD_NUMBER} -eq ${TRAVIS_BUILD_NUMBER} ]] && [[ ${FILE_TRAVIS_BUILD_STATUS} == "changes" ]]; then
  31. echo "Changes happen since last nightly release, let's continue"
  32. else
  33. echo "No changes since last nightly release, nothing else to do"
  34. exit 0
  35. fi
  36. else
  37. echo "File .travis/current_build_status doesn't exist, probably this is the very first build, let's continue"
  38. fi
  39. echo "--- Initialize git configuration ---"
  40. git checkout "${1-master}"
  41. git pull
  42. if [ "${RELEASE_CHANNEL}" == stable ]; then
  43. echo "--- Set default release channel to stable ---"
  44. sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' \
  45. netdata-installer.sh \
  46. packaging/makeself/install-or-update.sh
  47. fi
  48. # Everything from this directory will be uploaded to GCS
  49. mkdir -p artifacts
  50. BASENAME="netdata-$(git describe)"
  51. # Make sure stdout is in blocking mode. If we don't, then conda create will barf during downloads.
  52. # See https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 for details.
  53. 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);'
  54. echo "--- Create tarball ---"
  55. command -v git > /dev/null && [ -d .git ] && git clean -d -f
  56. autoreconf -ivf
  57. ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libexecdir=/usr/libexec --with-zlib --with-math --with-user=netdata CFLAGS=-O2
  58. make dist
  59. mv "${BASENAME}.tar.gz" artifacts/
  60. echo "--- Create self-extractor ---"
  61. sxarches="x86_64"
  62. for arch in ${sxarches}; do
  63. git clean -d -f
  64. rm -rf packating/makeself/tmp
  65. ./packaging/makeself/build-static.sh ${arch}
  66. done
  67. # Needed for GCS
  68. echo "--- Copy artifacts to separate directory ---"
  69. #shellcheck disable=SC2164
  70. cp packaging/version artifacts/latest-version.txt
  71. cd artifacts
  72. ln -s "${BASENAME}.tar.gz" netdata-latest.tar.gz
  73. for arch in ${sxarches}; do
  74. ln -s "netdata-${arch}-$(git describe).gz.run" netdata-${arch}-latest.gz.run
  75. done
  76. ln -s "${BASENAME}.gz.run" netdata-latest.gz.run
  77. sha256sum -b ./* > "sha256sums.txt"
  78. echo "checksums:"
  79. cat sha256sums.txt