summaryrefslogtreecommitdiffstats
path: root/.travis/releaser.sh
diff options
context:
space:
mode:
Diffstat (limited to '.travis/releaser.sh')
-rwxr-xr-x.travis/releaser.sh115
1 files changed, 72 insertions, 43 deletions
diff --git a/.travis/releaser.sh b/.travis/releaser.sh
index db43468de3..4da8f2472d 100755
--- a/.travis/releaser.sh
+++ b/.travis/releaser.sh
@@ -8,7 +8,7 @@
# Script to automatically do a couple of things:
# - generate a new tag according to semver (https://semver.org/)
# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator
-# - sync CHANGELOG with GitHub releases by using https://github.com/mattbrictson/chandler
+# - create draft of GitHub releases by using https://github.com/github/hub
#
# Tags are generated by searching for a keyword in last commit message. Keywords are:
# - [patch] or [fix] to bump patch number
@@ -19,10 +19,9 @@
# Script uses git mechanisms for locking, so it can be used in parallel builds
#
# Requirements:
-# - GH_TOKEN variable set with GitHub token. Access level: repo.public_repo
+# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo
# - docker
# - git-semver python package (pip install git-semver)
-#
if [ ! -f .gitignore ]
then
@@ -30,55 +29,85 @@ then
exit 1
fi
-# Exit when latest commit is tagged
-[[ $(git tag --points-at) ]] && exit 0
-
+echo "---- INITIALIZING CONFIGURATION -----"
# Some basic variables
GIT_MAIL="pawel+bot@netdata.cloud"
GIT_USER="netdatabot"
-# ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
-# PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
+ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
+PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
+HUB_VERSION=${HUB_VERSION:-"2.5.1"}
# Git config
-git config --global user.email "${GIT_MAIL}"
-git config --global user.name "${GIT_USER}"
+git config user.email "${GIT_MAIL}"
+git config user.name "${GIT_USER}"
GIT_URL=$(git config --get remote.origin.url)
GIT_URL=${GIT_URL#*//}
-# Figure out next tag based on commit message
-# OLD_TAG="$(git semver)"
-GIT_TAG=none
-echo "Last commit message: $TRAVIS_COMMIT_MESSAGE"
-case "${TRAVIS_COMMIT_MESSAGE}" in
- *"[patch]"*|*"[fix]"* ) GIT_TAG="v$(git semver --next-patch)" ;;
- *"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG="v$(git semver --next-minor)" ;;
- *"[major]"*|*"[breaking change]"* ) GIT_TAG="v$(git semver --next-major)" ;;
- *) echo "Keyword not detected. Doing nothing" ;;
-esac
+echo "---- FIGURING OUT TAGS-----"
+# Check if current commit is tagged or not
+GIT_TAG=$(git tag --points-at)
+if [ -z "${GIT_TAG}" ]; then
+ # Figure out next tag based on commit message
+ GIT_TAG=HEAD
+ echo "Last commit message: $TRAVIS_COMMIT_MESSAGE"
+ case "${TRAVIS_COMMIT_MESSAGE}" in
+ *"[patch]"*|*"[fix]"* ) GIT_TAG="v$(git semver --next-patch)" ;;
+ *"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG="v$(git semver --next-minor)" ;;
+ *"[major]"*|*"[breaking change]"* ) GIT_TAG="v$(git semver --next-major)" ;;
+ *) echo "Keyword not detected. Doing nothing" ;;
+ esac
-# Tag it!
-if [ "$GIT_TAG" != "none" ]; then
- echo "Assigning new tag: $GIT_TAG"
- git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
- git push "https://${GH_TOKEN}:@${GIT_URL}" --tags || exit 0
+ # Tag it!
+ if [ "$GIT_TAG" != "HEAD" ]; then
+ echo "Assigning a new tag: $GIT_TAG"
+ git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
+ git push "https://${GITHUB_TOKEN}:@${GIT_URL}" --tags || exit 0 # exits if tag exists
+ fi
fi
-## Generate CHANGELOG.md
-#git checkout master
-#git pull
+# If GIT_TAG is still having value "HEAD" then script entered a state where there was no keyword in commit msg and commit wasn't tagged.
+# This condition can be triggered by a cron job and it shouldn't create a release but might be still useful for changelog generation.
+
+echo "---- CREATING CHANGELOG -----"
+#PREV_TAG=$(git describe --abbrev=0 "${GIT_TAG}"^)
+git checkout master
+git pull
#docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
-# --user "${ORGANIZATION}" \
-# --token "${GH_TOKEN}" \
-# --project "${PROJECT}" \
-# --since-tag "${OLD_TAG}" \
-# --unreleased-label "**Next release**" --no-compare-link
-#
-#git add CHANGELOG.md
-#git commit -m '[ci skip] Automatic changelog update'
-#
-#git push "https://${GH_TOKEN}:@${GIT_URL}" || exit 0
-#
-## Sync changelog to github releases
-#if [ "$GIT_TAG" != "none" ]; then
-# docker run -e CHANDLER_GITHUB_API_TOKEN="${GH_TOKEN}" -v "$(pwd)":/chandler -ti whizark/chandler push "${GIT_TAG}"
-#fi
+docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \
+ --user "${ORGANIZATION}" \
+ --project "${PROJECT}" \
+ --token "${GITHUB_TOKEN}" \
+ --since-tag "v1.10.0" \
+ --unreleased-label "**Next release**" \
+ --no-compare-link \
+ --exclude-labels duplicate,question,invalid,wontfix,discussion,documentation
+
+echo "---- UPLOADING CHANGELOG -----"
+git add CHANGELOG.md
+git commit -m '[ci skip] Automatic changelog update'
+git push "https://${GITHUB_TOKEN}:@${GIT_URL}" || exit 0 # Exit if changlog was already uploaded
+
+if [ "${GIT_TAG}" == "HEAD" ]; then
+ echo "Not creating a release since neither of two conditions was met:"
+ echo " - keyword in commit message"
+ echo " - commit is tagged"
+ exit 0
+fi
+
+echo "---- CREATING RELEASE ARTIFACTS -----"
+python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
+
+./makeself/build-x86_64-static.sh
+make dist
+ln -s netdata-latest.gz.run "netdata-${GIT_TAG}.gz.run"
+ln -s netdata-*.tar.gz "netdata-${GIT_TAG}.tar.gz"
+sha256sum -b "netdata-${GIT_TAG}.gz.run" "netdata-${GIT_TAG}.tar.gz" > "sha256sums.txt"
+
+echo "---- CREATING RELEASE DRAFT WITH ASSETS -----"
+# Download hub
+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"
+tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz"
+export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
+
+# Create a release draft
+hub release create --draft -a "netdata-${GIT_TAG}.tar.gz" -a "netdata-${GIT_TAG}.gz.run" -a "sha256sums.txt" -m "${GIT_TAG}" "${GIT_TAG}"