@cryptotaxi247 / netdata-1 / commits / c33e3f75c

releaser (#4328)

Paweł Krupa committed Sep 30, 2018 at 20:07 UTC c33e3f75c8b9ccdb8df0df69a0d047828d27ab06
5 files changed +157 -17
.travis.yml
+16 -11
@@ -12,11 +12,9 @@ stages:
12 - test
13 - build
14 - name: release
15 - if: branch = master AND type = cron
16 -# TODO allow creating release on commit message
17 -# type = master AND \
18 -# type != pull_request AND \
19 -# ( type = cron OR commit_message =~ /[(major|minor|patch)]/ )
15 + if: branch = master AND type != pull_request
16 + - name: package
17 + if: branch = master AND type != pull_request
18
19 jobs:
20 include:
@@ -46,6 +44,7 @@ jobs:
44 script: ./coverity-scan.sh || echo "Coverity failed :("
45 env: INSTALL_COVERITY="true"
46 if: type = cron
47 +
48 - stage: "build"
49 name: "OSX"
50 install: brew install fakeroot ossp-uuid
@@ -62,12 +61,13 @@ jobs:
61 script: ./.travis/containerized_build.sh centos6
62 - name: "alpine"
63 script: ./.travis/containerized_build.sh alpine
64 +
65 - stage: "release"
66 - name: "Docker"
67 - install: sudo apt update -y && sudo apt install -y --only-upgrade docker-ce && docker info
68 - script: docker/build.sh
69 - env: REPOSITORY="netdata/netdata"
70 - - name: "GitHub"
66 + name: "Create release"
67 + script: .travis/releaser.sh
68 +
69 + - stage: "package"
70 + name: "Archive and self-extractor"
71 install: sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot
72 script: .travis/create_artifacts.sh
73 deploy:
@@ -78,11 +78,16 @@ jobs:
78 skip_cleanup: true
79 file_glob: true
80 file:
81 - - "netdata*.tar.*"
81 + - "netdata*.tar.gz*"
82 - "netdata*.gz.run*"
83 + - "sha256sums.txt"
84 on:
85 repo: netdata/netdata
86 tags: true
87 + - name: "Docker images"
88 + script: docker/build.sh
89 + env: REPOSITORY="netdata/netdata"
90 + if: type = cron OR tag =~ ^v
91
92 notifications:
93 webhooks: https://app.fossa.io/hooks/travisci
.travis/README.md
+54 -3
@@ -1,9 +1,60 @@
1 -# Variables needed by travis
1 +# Description of CI build configuration
2 +
3 +## Variables needed by travis
4
5 - GH_TOKEN - GitHub token with push access to repository
6 - DOCKER_USERNAME - Username (netdatabot) with write access to docker hub repository
7 - DOCKER_PASSWORD - Password to docker hub
6 -- encrypted_decb6f6387c4_key - Something to do with package releasing (need more info from @philwhineray)
7 -- encrypted_decb6f6387c4_iv - Something to do with package releasing (need more info from @philwhineray)
8 +- encrypted_decb6f6387c4_key - Something to do with package releasing (soon to be deprecated)
9 +- encrypted_decb6f6387c4_iv - Something to do with package releasing (soon to be deprecated)
10 - OLD_DOCKER_USERNAME - Username used to push images to firehol/netdata # TODO: remove after deprecating that repo
11 - OLD_DOCKER_PASSWORD - Password used to push images to firehol/netdata # TODO: remove after deprecating that repo
12 +
13 +## Stages
14 +
15 +### Lint
16 +
17 +Stage is executed every time and consists of 4 parallel jobs which check for any deviation from coding conventions.
18 +Checks are performed using:
19 + - csslint (CSS)
20 + - eslint (JS)
21 + - shellcheck (shell scripts)
22 + - flake8 (python)
23 +
24 +Ideally any error should cause whole CI pipeline to fail. Unfortunatelly right now only shellcheck and eslint are
25 +causing pipeline to fail.
26 +
27 +### Test
28 +
29 +Unit tests and coverage tests are executed here. Stage consists of 2 parallel jobs:
30 + - C tests - executed every time
31 + - coverity test - executed only when pipeline was triggered from cron
32 +
33 +### Build
34 +
35 +Stage is executed every time and consists of 5 parallel jobs which execute containerized and non-containerized
36 +installations of netdata. Jobs are run on following operating systems:
37 + - OSX
38 + - ubuntu 14.04
39 + - ubuntu 16.04 (containerized)
40 + - CentOS 6 (containerized)
41 + - CentOS 7 (containerized)
42 +
43 +### Release
44 +
45 +This stage is executed only on "master" brach and allows us to create a new tag just looking at git commit message.
46 +It also has an option to automatically generate changelog based on GitHub labels and sync it with GitHub release.
47 +For the sake of simplicity and to use travis features this stage cannot be integrated with next stage.
48 +
49 +### Packages
50 +
51 +As a name might suggest, this stage is responsible for creating netdata packages such as:
52 + - docker images
53 + - tar repository (soon to be removed)
54 + - self-extracting package
55 +
56 +This stage is separated into 2 parallel jobs. One creating docker images and second one creating github artifacts.
57 +Whole stage is executed only on master branch, but there are also additional parameters assigned to jobs:
58 + - docker images - execution only on cron job or when there is a tag assigned starting with `v`
59 + - artifacts - script responsible for creating artifacts doesn't have special conditions, but deployment to GitHub
60 + releases is done only when there is tag assigned
.travis/create_artifacts.sh
+1
@@ -22,4 +22,5 @@ python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL);
22 ./makeself/build-x86_64-static.sh
23 for i in *.tar.gz; do sha512sum -b "$i" > "$i.sha"; done
24 for i in *.gz.run; do sha512sum -b "$i" > "$i.sha"; done
25 +sha256sum -b ./*.tar.gz ./*.gz.run > "sha256sums.txt"
26 ./.travis/deploy-if-have-key
.travis/releaser.sh new
+84
@@ -0,0 +1,84 @@
1 +#!/bin/bash
2 +# SPDX-License-Identifier: MIT
3 +# Copyright (C) 2018 Pawel Krupa (@paulfantom) - All Rights Reserved
4 +# Permission to copy and modify is granted under the MIT license
5 +#
6 +# Original script is available at https://github.com/paulfantom/travis-helper/blob/master/releasing/releaser.sh
7 +#
8 +# Script to automatically do a couple of things:
9 +# - generate a new tag according to semver (https://semver.org/)
10 +# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator
11 +# - sync CHANGELOG with GitHub releases by using https://github.com/mattbrictson/chandler
12 +#
13 +# Tags are generated by searching for a keyword in last commit message. Keywords are:
14 +# - [patch] or [fix] to bump patch number
15 +# - [minor], [feature] or [feat] to bump minor number
16 +# - [major] or [breaking change] to bump major number
17 +# All keywords MUST be surrounded with square braces.
18 +#
19 +# Script uses git mechanisms for locking, so it can be used in parallel builds
20 +#
21 +# Requirements:
22 +# - GH_TOKEN variable set with GitHub token. Access level: repo.public_repo
23 +# - docker
24 +# - git-semver python package (pip install git-semver)
25 +#
26 +
27 +if [ ! -f .gitignore ]
28 +then
29 + echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
30 + exit 1
31 +fi
32 +
33 +# Exit when latest commit is tagged
34 +[[ $(git tag --points-at) ]] && exit 0
35 +
36 +# Some basic variables
37 +GIT_MAIL="pawel+bot@netdata.cloud"
38 +GIT_USER="netdatabot"
39 +# ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
40 +# PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
41 +
42 +# Git config
43 +git config --global user.email "${GIT_MAIL}"
44 +git config --global user.name "${GIT_USER}"
45 +GIT_URL=$(git config --get remote.origin.url)
46 +GIT_URL=${GIT_URL#*//}
47 +
48 +# Figure out next tag based on commit message
49 +# OLD_TAG="$(git semver)"
50 +GIT_TAG=none
51 +echo "Last commit message: $TRAVIS_COMMIT_MESSAGE"
52 +case "${TRAVIS_COMMIT_MESSAGE}" in
53 + *"[patch]"*|*"[fix]"* ) GIT_TAG="v$(git semver --next-patch)" ;;
54 + *"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG="v$(git semver --next-minor)" ;;
55 + *"[major]"*|*"[breaking change]"* ) GIT_TAG="v$(git semver --next-major)" ;;
56 + *) echo "Keyword not detected. Doing nothing" ;;
57 +esac
58 +
59 +# Tag it!
60 +if [ "$GIT_TAG" != "none" ]; then
61 + echo "Assigning new tag: $GIT_TAG"
62 + git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
63 + git push "https://${GH_TOKEN}:@${GIT_URL}" --tags || exit 0
64 +fi
65 +
66 +## Generate CHANGELOG.md
67 +#git checkout master
68 +#git pull
69 +#docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
70 +# --user "${ORGANIZATION}" \
71 +# --token "${GH_TOKEN}" \
72 +# --project "${PROJECT}" \
73 +# --since-tag "${OLD_TAG}" \
74 +# --unreleased-label "**Next release**" --no-compare-link
75 +#
76 +#git add CHANGELOG.md
77 +#git commit -m '[ci skip] Automatic changelog update'
78 +#
79 +#git push "https://${GH_TOKEN}:@${GIT_URL}" || exit 0
80 +#
81 +## Sync changelog to github releases
82 +#if [ "$GIT_TAG" != "none" ]; then
83 +# docker run -e CHANDLER_GITHUB_API_TOKEN="${GH_TOKEN}" -v "$(pwd)":/chandler -ti whizark/chandler push "${GIT_TAG}"
84 +#fi
docker/build.sh
+2 -3
@@ -8,9 +8,8 @@ set -e
8
9 REPOSITORY="${REPOSITORY:-netdata}"
10
11 -if [ ${VERSION+x} ]; then
12 - VERSION="${VERSION}"
13 -else
11 +VERSION=$(git tag --points-at)
12 +if [ "${VERSION}" == "" ]; then
13 VERSION="latest"
14 fi
15