generate_changelog_for_nightlies.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 config user.email "${GIT_MAIL}"
  38. git config user.name "${GIT_USER}"
  39. git checkout master
  40. git pull
  41. echo "Running project markmandel for github changelog generation"
  42. #docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
  43. docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \
  44. --user "${ORG}" \
  45. --project "${PROJECT}" \
  46. --token "${GITHUB_TOKEN}" \
  47. --since-tag "v1.10.0" \
  48. --unreleased-label "**Next release**" \
  49. --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
  50. --no-compare-link ${OPTS}
  51. echo "Changelog created! Adding packaging/version(${NEW_VERSION}) and CHANGELOG.md to the repository"
  52. echo "${NEW_VERSION}" > packaging/version
  53. git add packaging/version && echo "1) Added packaging/version to repository" || FAIL=1
  54. git add CHANGELOG.md && echo "2) Added changelog file to repository" || FAIL=1
  55. git commit -m '[ci skip] create nightly packages and update changelog' && echo "3) Committed changes to repository" || FAIL=1
  56. git push "https://${GITHUB_TOKEN}:@${PUSH_URL}" && echo "4) Pushed changes to remote ${PUSH_URL}" || FAIL=1
  57. # In case of a failure, wrap it up and bail out cleanly
  58. if [ $FAIL -eq 1 ]; then
  59. git clean -xfd
  60. echo "Changelog generation failed during github UPDATE!"
  61. exit 1
  62. fi
  63. echo "Changelog generation completed successfully!"