generate_changelog_for_nightlies.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. #
  3. # Changelog generation scriptlet.
  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. ORG=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f1)
  22. PROJECT=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 2)
  23. GIT_MAIL=${GIT_MAIL:-"bot@netdata.cloud"}
  24. GIT_USER=${GIT_USER:-"netdatabot"}
  25. PUSH_URL=$(git config --get remote.origin.url | sed -e 's/^https:\/\///')
  26. FAIL=0
  27. if [ -z ${GIT_TAG+x} ]; then
  28. OPTS=""
  29. else
  30. OPTS="--future-release ${GIT_TAG}"
  31. fi
  32. echo "We got $COMMITS_SINCE_RELEASE changes since $LAST_TAG, re-generating changelog"
  33. if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
  34. echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing else to do here"
  35. exit 0
  36. fi
  37. git checkout master
  38. git pull
  39. echo "Running project markmandel for github changelog generation"
  40. #docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
  41. docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \
  42. --user "${ORG}" \
  43. --project "${PROJECT}" \
  44. --token "${GITHUB_TOKEN}" \
  45. --since-tag "v1.10.0" \
  46. --unreleased-label "**Next release**" \
  47. --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
  48. --no-compare-link ${OPTS}
  49. echo "Changelog created! Adding packaging/version(${NEW_VERSION}) and CHANGELOG.md to the repository"
  50. echo "${NEW_VERSION}" > packaging/version
  51. git add packaging/version && echo "1) Added packaging/version to repository" || FAIL=1
  52. git add CHANGELOG.md && echo "2) Added changelog file to repository" || FAIL=1
  53. git commit -m '[ci skip] create nightly packages and update changelog' --author "${GIT_USER} <${GIT_MAIL}>" && echo "3) Committed changes to repository" || FAIL=1
  54. git push "https://${GITHUB_TOKEN}:@${PUSH_URL}" && echo "4) Pushed changes to remote ${PUSH_URL}" || FAIL=1
  55. # In case of a failure, wrap it up and bail out cleanly
  56. if [ $FAIL -eq 1 ]; then
  57. git clean -xfd
  58. echo "Changelog generation failed during github UPDATE!"
  59. exit 1
  60. fi
  61. echo "Changelog generation completed successfully!"