draft_release.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. #
  3. # Draft release generator.
  4. # This utility is responsible for submitting a draft release to github repo
  5. # It is agnostic of other processes, when executed it will draft a release,
  6. # based on the most recent reachable tag.
  7. #
  8. # Requirements:
  9. # - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo
  10. # - artifacts directory in place
  11. # - The directory is created by create_artifacts.sh mechanism
  12. # - The artifacts need to be created with the same tag, obviously
  13. #
  14. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  15. #
  16. # Author: Pavlos Emm. Katsoulakis <paul@netdata.cloud>
  17. set -e
  18. if [ ! -f .gitignore ]; then
  19. echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
  20. exit 1
  21. fi
  22. echo "--- Initialize git configuration ---"
  23. git checkout master
  24. git pull
  25. if [[ $(git describe) =~ -rc* ]]; then
  26. echo "This is a release candidate tag, we do not generate a release draft"
  27. exit 0
  28. fi
  29. # Load the tag, if any
  30. GIT_TAG=$(git describe)
  31. if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
  32. echo "Beta mode on ${TRAVIS_REPO_SLUG}, i was about to run for release (${GIT_TAG}), but i am emulating, so bye"
  33. exit 0
  34. fi;
  35. echo "---- CREATING RELEASE DRAFT WITH ASSETS -----"
  36. # Download hub
  37. HUB_VERSION=${HUB_VERSION:-"2.5.1"}
  38. wget "https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-linux-amd64-${HUB_VERSION}.tgz" -O "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz"
  39. tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz"
  40. export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
  41. # Create a release draft
  42. if [ -z ${GIT_TAG+x} ]; then
  43. echo "Variable GIT_TAG is not set. Something went terribly wrong! Exiting."
  44. exit 1
  45. fi
  46. if [ "${GIT_TAG}" != "$(git tag --points-at)" ]; then
  47. echo "ERROR! Current commit is not tagged. Stopping release creation."
  48. exit 1
  49. fi
  50. until hub release create --draft \
  51. -a "artifacts/netdata-${GIT_TAG}.tar.gz" \
  52. -a "artifacts/netdata-${GIT_TAG}.gz.run" \
  53. -a "artifacts/sha256sums.txt" \
  54. -m "${GIT_TAG}" "${GIT_TAG}"; do
  55. sleep 5
  56. done