summaryrefslogtreecommitdiffstats
path: root/.travis
diff options
context:
space:
mode:
authorPaweł Krupa <pawel@krupa.net.pl>2018-10-31 17:02:50 +0100
committerCosta Tsaousis <costa@tsaousis.gr>2018-10-31 18:02:50 +0200
commit97187d52dba058f66cb82dc60a2062e1122e9486 (patch)
tree9ad14b643af8a85b166fa957339f982d86a29749 /.travis
parent965209fff3b57514cc2857a9ba72c9ffc64a3538 (diff)
new releaser (#4526)
Diffstat (limited to '.travis')
-rw-r--r--.travis/README.md21
-rwxr-xr-x.travis/releaser.sh115
2 files changed, 80 insertions, 56 deletions
diff --git a/.travis/README.md b/.travis/README.md
index 57efa9a122..c737b5aba0 100644
--- a/.travis/README.md
+++ b/.travis/README.md
@@ -2,7 +2,7 @@
## Variables needed by travis
-- GH_TOKEN - GitHub token with push access to repository
+- GITHUB_TOKEN - GitHub token with push access to repository
- DOCKER_USERNAME - Username (netdatabot) with write access to docker hub repository
- DOCKER_PASSWORD - Password to docker hub
- encrypted_decb6f6387c4_key - Something to do with package releasing (soon to be deprecated)
@@ -12,18 +12,6 @@
## Stages
-### Lint
-
-Stage is executed every time and consists of 4 parallel jobs which check for any deviation from coding conventions.
-Checks are performed using:
- - csslint (CSS)
- - eslint (JS)
- - shellcheck (shell scripts)
- - flake8 (python)
-
-Ideally any error should cause whole CI pipeline to fail. Unfortunatelly right now only shellcheck and eslint are
-causing pipeline to fail.
-
### Test
Unit tests and coverage tests are executed here. Stage consists of 2 parallel jobs:
@@ -46,6 +34,13 @@ This stage is executed only on "master" brach and allows us to create a new tag
It also has an option to automatically generate changelog based on GitHub labels and sync it with GitHub release.
For the sake of simplicity and to use travis features this stage cannot be integrated with next stage.
+Releases are generated by searching for a keyword in last commit message. Keywords are:
+ - [patch] or [fix] to bump patch number
+ - [minor], [feature] or [feat] to bump minor number
+ - [major] or [breaking change] to bump major number
+All keywords MUST be surrounded with square braces.
+Alternative is to push a tag to master branch.
+
### Packages
As a name might suggest, this stage is responsible for creating netdata packages such as:
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}"