generate_changelog_for_nightlies.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. #
  3. # Changelog generation scriptlet, for nightlies
  4. #
  5. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  6. #
  7. # Author : Pawel Krupa (paulfantom)
  8. # Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
  9. set -e
  10. # If we are not in netdata git repo, at the top level directory, fail
  11. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  12. CWD=$(git rev-parse --show-cdup || echo "")
  13. if [ -n "$CWD" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  14. echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
  15. echo "Changelog generation process aborted"
  16. exit 1
  17. fi
  18. LAST_TAG="$1"
  19. COMMITS_SINCE_RELEASE="$2"
  20. NEW_VERSION="${LAST_TAG}-$((COMMITS_SINCE_RELEASE + 1))-nightly"
  21. GIT_MAIL=${GIT_MAIL:-"bot@netdata.cloud"}
  22. GIT_USER=${GIT_USER:-"netdatabot"}
  23. PUSH_URL=$(git config --get remote.origin.url | sed -e 's/^https:\/\///')
  24. FAIL=0
  25. if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
  26. echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing else to do here"
  27. exit 0
  28. fi
  29. echo "Running changelog creation mechanism"
  30. .travis/create_changelog.sh
  31. echo "Changelog created! Adding packaging/version(${NEW_VERSION}) and CHANGELOG.md to the repository"
  32. echo "${NEW_VERSION}" > packaging/version
  33. git add packaging/version && echo "1) Added packaging/version to repository" || FAIL=1
  34. git add CHANGELOG.md && echo "2) Added changelog file to repository" || FAIL=1
  35. git commit -m '[ci skip] create nightly packages and update changelog' --author "${GIT_USER} <${GIT_MAIL}>" && echo "3) Committed changes to repository" || FAIL=1
  36. git push "https://${GITHUB_TOKEN}:@${PUSH_URL}" && echo "4) Pushed changes to remote ${PUSH_URL}" || FAIL=1
  37. # In case of a failure, wrap it up and bail out cleanly
  38. if [ $FAIL -eq 1 ]; then
  39. git clean -xfd
  40. echo "Changelog generation failed during github UPDATE!"
  41. exit 1
  42. fi
  43. echo "Changelog generation completed successfully!"