trigger_package_generation.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. #
  3. # Trigger .RPM and .DEB package generation processes
  4. #
  5. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  6. #
  7. # Author: Pavlos Emm. Katsoulakis <paul@netdata.cloud>
  8. set -e
  9. WAIT_TIME=15
  10. BUILD_NIGHTLY="$1"
  11. commit_change() {
  12. local ARCH="$1"
  13. local PKG="$2"
  14. local GIT_MAIL="bot@netdata.cloud"
  15. local GIT_USER="netdatabot"
  16. echo "---- Committing ${ARCH} .${PKG} package generation ----"
  17. git commit --allow-empty --author "${GIT_USER} <${GIT_MAIL}>" -m "[Package ${ARCH} ${PKG}]${BUILD_NIGHTLY} Package build process trigger"
  18. }
  19. push_change() {
  20. echo "---- Push changes to repository ----"
  21. git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
  22. }
  23. # If we are not in netdata git repo, at the top level directory, fail
  24. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  25. CWD=$(git rev-parse --show-cdup || echo "")
  26. if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  27. echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
  28. echo "Changelog generation process aborted"
  29. exit 1
  30. fi
  31. echo "--- Initialize git configuration ---"
  32. git checkout master
  33. git fetch --all
  34. git pull
  35. commit_change "amd64" "DEB"
  36. push_change
  37. echo "---- Waiting for ${WAIT_TIME} seconds before triggering next process ----"
  38. sleep "${WAIT_TIME}"
  39. commit_change "i386" "DEB"
  40. push_change
  41. echo "---- Waiting for ${WAIT_TIME} seconds before triggering next process ----"
  42. sleep "${WAIT_TIME}"
  43. commit_change "amd64" "RPM"
  44. push_change
  45. echo "---- Done! ----"