summaryrefslogtreecommitdiffstats
path: root/.travis
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.travis.yml85
-rw-r--r--.travis/README.md27
-rwxr-xr-x.travis/containerized_build.sh7
-rwxr-xr-x.travis/create_artifacts.sh37
-rw-r--r--.travis/gcs-credentials.json.encbin0 -> 2320 bytes
-rwxr-xr-x.travis/generate_changelog.sh33
-rw-r--r--.travis/images/Dockerfile.alpine5
-rw-r--r--.travis/images/Dockerfile.centos65
-rw-r--r--.travis/images/Dockerfile.centos75
-rw-r--r--.travis/images/Dockerfile.ubuntu18046
-rwxr-xr-x.travis/labeler.sh105
-rwxr-xr-x.travis/nightlies.sh45
-rwxr-xr-x.travis/releaser.sh40
-rwxr-xr-x.travis/tagger.sh42
14 files changed, 305 insertions, 137 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..248e627a2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,85 @@
+dist: trusty
+sudo: true
+language: c
+services:
+- docker
+
+stages:
+- test
+- build
+- name: packaging
+ if: branch = master AND type != pull_request AND type != cron
+- name: nightlies
+ if: branch = master AND type = cron
+
+jobs:
+ include:
+ - stage: test
+ name: C
+ install: sudo apt-get install -y libcap2-bin zlib1g-dev uuid-dev fakeroot libipmimonitoring-dev libmnl-dev libnetfilter-acct-dev
+ script: fakeroot ./netdata-installer.sh --install $HOME --dont-wait --dont-start-it --enable-plugin-nfacct --enable-plugin-freeipmi --disable-lto && $HOME/netdata/usr/sbin/netdata -W unittest
+ env: CFLAGS='-O1 -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_VERIFY_LOCKS=1'
+ - name: dashboard.js
+ script: cp web/gui/dashboard.js /tmp/dashboard.js && ./build/build.sh && diff /tmp/dashboard.js web/gui/dashboard.js
+ - name: coverity
+ install: sudo apt-get install -y zlib1g-dev uuid-dev libipmimonitoring-dev libmnl-dev libnetfilter-acct-dev
+ script: ./coverity-scan.sh || echo "Coverity failed :("
+ env: INSTALL_COVERITY="true"
+ if: type = cron
+
+ - stage: build
+# TODO(paulfantom): enable when travis OSX become stable. Probably after 12.01.2019
+# name: OSX
+# install: brew install fakeroot ossp-uuid
+# script: fakeroot ./netdata-installer.sh --install $HOME --dont-wait --dont-start-it
+# os: osx
+# - name: ubuntu 14.04 (not containerized)
+ name: ubuntu 14.04 (not containerized)
+ install: sudo apt-get install -y libcap2-bin zlib1g-dev uuid-dev fakeroot
+ script: fakeroot ./netdata-installer.sh --dont-wait --dont-start-it --install $HOME
+ - name: build container (alpine installation)
+ script: ./packaging/docker/build.sh
+ env: DEVEL="true"
+ - name: ubuntu 18.04 + lifecycle
+ script: docker run -it -v "${PWD}:/code:rw" -w /code "netdata/os-test:ubuntu1804" bats --tap tests/lifecycle.bats
+ - name: CentOS 7
+ script: docker run -it -v "${PWD}:/code:rw" -w /code "netdata/os-test:centos7" ./netdata-installer.sh --dont-wait --dont-start-it --install /tmp
+ - name: CentOS 6
+ script: docker run -it -v "${PWD}:/code:rw" -w /code "netdata/os-test:centos6" ./netdata-installer.sh --dont-wait --dont-start-it --install /tmp
+
+ - stage: packaging
+ name: Create release (only on special commit msg)
+ install:
+ - sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot python-pip
+ - sudo apt install -y --only-upgrade docker-ce
+ - docker info
+ before_script: sudo pip install git-semver
+ script: ".travis/releaser.sh && .travis/labeler.sh" # labeler should be replaced with GitHub Actions when they hit GA
+ git:
+ depth: false
+
+ - stage: nightlies
+ name: Nightly build
+ before_install: openssl aes-256-cbc -K $encrypted_8daf19481253_key -iv $encrypted_8daf19481253_iv -in .travis/gcs-credentials.json.enc -out .travis/gcs-credentials.json -d
+ install:
+ - sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot
+ - sudo apt install -y --only-upgrade docker-ce
+ - docker info
+ script: ".travis/nightlies.sh"
+ git:
+ depth: false
+ deploy:
+ provider: gcs
+ edge:
+ branch: gcs-ng
+ project_id: netdata-storage
+ credentials: .travis/gcs-credentials.json
+ bucket: "netdata-nightlies"
+ skip_cleanup: true
+ local_dir: "artifacts"
+
+notifications:
+ webhooks: https://app.fossa.io/hooks/travisci
+ slack:
+ rooms:
+ - secure: "NuW1p7s+WGLcyhEceeiLRSV1JgAc6N47zgdSsYoxrjSFRQHDfc8jensypDcEJwgs1K2Hcve9iKRaAddEHEw7AkS6rie9gFR5HmmbKXfW2GFMqOr6maYTFsvaECPqiWk1n9/XnRLsAi5kZ8HxH+a8ldb/eaVoFQesY1jPXgh11BM5DwvpXjEtwg0WGASsKiymvnXFS3KcC+sR7Lln2GX1a8vfCX2I3TEmOedKMlSHUy5JilGGC3AWA0SWS8tR8PUH0u3dHL5j0RNIr1RO3Yx24QgUpg/YpvKymnW/iIIEOq2vb2mBhhiKEQjJ1djUL4VSPzjIDpUzThVpKaHk3syOp6W9qZEHKhR/sqjc5Yk2XRjsw1cM0nS60gaCgxtKhEMKWcjtvWf04oJAVrmcUwcYXj0eA+jgRCZl5VhyufK/fUJavjOfsQGjwhdjxQfwDCw33W17ypJUt4GZngdb6jbIhEOcKHSLQDu1vuHTw82hJJkthkmR59PX30qJdl/MEGcfVLdN/fkCokjR/qwfmkNwQm+wYSKsK/Jq4RgBT0/oZwY3e8nkCq2ov7lBbDO3/0rzQKWZ9Uy//tnoCM3vGhDwGHQxsHshv7g6KwdhYTcmm7WWWIucfLupcjFUO1HbRuJ+7ZnvxRRwKiV+MGkFT2SNJkS8q1/jCu9KGbmktd0WUSE="
diff --git a/.travis/README.md b/.travis/README.md
index e37e9feff..d67df293d 100644
--- a/.travis/README.md
+++ b/.travis/README.md
@@ -5,10 +5,9 @@
- 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)
-- encrypted_decb6f6387c4_iv - Something to do with package releasing (soon to be deprecated)
-- OLD_DOCKER_USERNAME - Username used to push images to firehol/netdata # TODO: remove after deprecating that repo
-- OLD_DOCKER_PASSWORD - Password used to push images to firehol/netdata # TODO: remove after deprecating that repo
+- encrypted_8daf19481253_key - key needed by openssl to decrypt GCS credentials file
+- encrypted_8daf19481253_iv - IV needed by openssl to decrypt GCS credentials file
+- COVERITY_SCAN_TOKEN - Token to allow coverity test analysis uploads
## Stages
@@ -16,6 +15,7 @@
Unit tests and coverage tests are executed here. Stage consists of 2 parallel jobs:
- C tests - executed every time
+ - dashboard.js - test if source files create the same file as it is in current repo
- coverity test - executed only when pipeline was triggered from cron
### Build
@@ -29,18 +29,23 @@ installations of netdata. Jobs are run on following operating systems:
- CentOS 7 (containerized)
- alpine (containerized)
+Images for system containers are stored on dockerhub and are created from Dockerfiles located in
+[netdata/helper-images](https://github.com/netdata/helper-images) repository.
+
### Packaging
This stage is executed only on "master" brach and allows us to create a new tag just looking at git commit message.
It executes one script called `releaser.sh` which is responsible for creating a release on GitHub by using
[hub](https://github.com/github/hub). This script is also executing other scripts which can also be used in other
CI jobs:
- - `tagger.sh`
- - `generate_changelog.sh`
- - `build.sh`
- - `create_artifacts.sh`
+ - `.travis/tagger.sh`
+ - `.travis/generate_changelog.sh`
+ - `packaging/docker/build.sh`
+ - `.travis/create_artifacts.sh`
Alternatively new release can be also created by pushing new tag to master branch.
+Additionally this step is also executing `.travis/labeler.sh` which is a temporary workaround to automatically label
+issues and PR. This script should be replaced with GitHub Actions when they are available to public.
##### tagger.sh
@@ -77,12 +82,10 @@ This is achieved by running 2 scripts described earlier:
- `create_artifacts.sh`
- `build.sh`
+Artifacts are pushed to GCS and container images are stored in docker hub.
+
##### Changelog generation
This job is responsible for regenerating changelog every day by executing `generate_changelog.sh` script. This is done
only once a day due to github rate limiter.
-##### Labeler
-
-Once a day we are doing automatic label assignment by executing `labeler.sh`. This script is a temporary workaround until
-we start using GitHub Actions. For more information what it is currently doing go to its code.
diff --git a/.travis/containerized_build.sh b/.travis/containerized_build.sh
deleted file mode 100755
index 314a2ec39..000000000
--- a/.travis/containerized_build.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-set -e
-
-docker build -t dev-image -f ".travis/images/Dockerfile.$1" .
-
-docker run -it -w /code dev-image ./netdata-installer.sh --dont-wait --dont-start-it --install /tmp
diff --git a/.travis/create_artifacts.sh b/.travis/create_artifacts.sh
index 40ba9c85f..ca0724e19 100755
--- a/.travis/create_artifacts.sh
+++ b/.travis/create_artifacts.sh
@@ -1,33 +1,36 @@
#!/bin/bash
# shellcheck disable=SC2230
-if [ ! -f .gitignore ]
-then
- echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
- exit 1
+set -e
+
+if [ ! -f .gitignore ]; then
+ echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
+ exit 1
fi
+# Everything from this directory will be uploaded to GCS
+mkdir -p artifacts
+BASENAME="netdata-$(git describe)"
+
# Make sure stdout is in blocking mode. If we don't, then conda create will barf during downloads.
# See https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 for details.
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);'
echo "--- Create tarball ---"
autoreconf -ivf
-./configure
+./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-zlib --with-math --with-user=netdata CFLAGS=-O2
make dist
-echo "--- Create self-extractor ---"
-./makeself/build-x86_64-static.sh
+mv "${BASENAME}.tar.gz" artifacts/
-echo "--- Create checksums ---"
-GIT_TAG=$(git tag --points-at)
-if [ "${GIT_TAG}" != "" ]; then
- 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"
-else
- sha256sum -b ./*.tar.gz ./*.gz.run > "sha256sums.txt"
-fi
+echo "--- Create self-extractor ---"
+./packaging/makeself/build-x86_64-static.sh
+# Needed fo GCS
+echo "--- Copy artifacts to separate directory ---"
+#shellcheck disable=SC2164
+cd artifacts
+ln -s "${BASENAME}.tar.gz" netdata-latest.tar.gz
+ln -s "${BASENAME}.gz.run" netdata-latest.gz.run
+sha256sum -b ./* >"sha256sums.txt"
echo "checksums:"
cat sha256sums.txt
-
diff --git a/.travis/gcs-credentials.json.enc b/.travis/gcs-credentials.json.enc
new file mode 100644
index 000000000..5d1e7b2dd
--- /dev/null
+++ b/.travis/gcs-credentials.json.enc
Binary files differ
diff --git a/.travis/generate_changelog.sh b/.travis/generate_changelog.sh
index d9b91113a..d1b72e071 100755
--- a/.travis/generate_changelog.sh
+++ b/.travis/generate_changelog.sh
@@ -2,10 +2,9 @@
set -e
-if [ ! -f .gitignore ]
-then
- echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
- exit 1
+if [ ! -f .gitignore ]; then
+ echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
+ exit 1
fi
ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
@@ -13,24 +12,22 @@ PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
GIT_MAIL=${GIT_MAIL:-"pawel+bot@netdata.cloud"}
GIT_USER=${GIT_USER:-"netdatabot"}
-echo "--- Initialize git configuration ---"
-git config user.email "${GIT_MAIL}"
-git config user.name "${GIT_USER}"
+if [ -z ${GIT_TAG+x} ]; then
+ OPTS=""
+else
+ OPTS="--future-release ${GIT_TAG}"
+fi
echo "--- Creating changelog ---"
git checkout master
git pull
#docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
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
+ --user "${ORGANIZATION}" \
+ --project "${PROJECT}" \
+ --token "${GITHUB_TOKEN}" \
+ --since-tag "v1.10.0" \
+ --unreleased-label "**Next release**" \
+ --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
+ --no-compare-link ${OPTS}
-echo "--- Uploading changelog ---"
-git add CHANGELOG.md
-git commit -m '[ci skip] Automatic changelog update' || exit 0
-git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
diff --git a/.travis/images/Dockerfile.alpine b/.travis/images/Dockerfile.alpine
deleted file mode 100644
index 15f527165..000000000
--- a/.travis/images/Dockerfile.alpine
+++ /dev/null
@@ -1,5 +0,0 @@
-FROM alpine:latest
-
-RUN apk add bash gcc make autoconf automake pkgconfig zlib-dev libuuid git libmnl-dev util-linux-dev build-base
-
-COPY . /code
diff --git a/.travis/images/Dockerfile.centos6 b/.travis/images/Dockerfile.centos6
deleted file mode 100644
index c286fb95c..000000000
--- a/.travis/images/Dockerfile.centos6
+++ /dev/null
@@ -1,5 +0,0 @@
-FROM centos:6
-
-RUN yum install -y gcc make autoconf automake pkg-config zlib-devel libuuid-devel git
-
-COPY . /code
diff --git a/.travis/images/Dockerfile.centos7 b/.travis/images/Dockerfile.centos7
deleted file mode 100644
index d94359dec..000000000
--- a/.travis/images/Dockerfile.centos7
+++ /dev/null
@@ -1,5 +0,0 @@
-FROM centos:7
-
-RUN yum install -y gcc make autoconf automake pkg-config zlib-devel libuuid-devel git
-
-COPY . /code
diff --git a/.travis/images/Dockerfile.ubuntu1804 b/.travis/images/Dockerfile.ubuntu1804
deleted file mode 100644
index 30ac7cf71..000000000
--- a/.travis/images/Dockerfile.ubuntu1804
+++ /dev/null
@@ -1,6 +0,0 @@
-FROM ubuntu:18.04
-
-RUN apt-get update && \
- apt-get install -y gcc make autoconf automake pkg-config zlib1g-dev uuid-dev git
-
-COPY . /code
diff --git a/.travis/labeler.sh b/.travis/labeler.sh
index 47bf250a0..e8d7d228d 100755
--- a/.travis/labeler.sh
+++ b/.travis/labeler.sh
@@ -3,30 +3,95 @@
# This is a simple script which should apply labels to unlabelled issues from last 3 days.
# It will soon be deprecated by GitHub Actions so no futher development on it is planned.
+# Previously this was using POST to only add labels. But this method seems to be failing with larger number of requests
+new_labels() {
+ ISSUE="$1"
+ URL="https://api.github.com/repos/netdata/netdata/issues/$ISSUE/labels"
+ # deduplicate array and add quotes
+ SET=( $(for i in "${@:2}"; do [ "$i" != "" ] && echo "\"$i\""; done | sort -u) )
+ # implode array to string
+ LABELS="${SET[*]}"
+ # add commas between quotes (replace spaces)
+ LABELS="${LABELS//\" \"/\",\"}"
+ # remove duplicate quotes in case parameters were already quoted
+ LABELS="${LABELS//\"\"/\"}"
+ echo "-------- Assigning labels to #${ISSUE}: ${LABELS} --------"
+ curl -H "Authorization: token $GITHUB_TOKEN" -d "{\"labels\":[${LABELS}]}" -X PUT "${URL}" &>/dev/null
+}
+
if [ "$GITHUB_TOKEN" == "" ]; then
- echo "GITHUB_TOKEN is needed"
- exit 1
+ echo "GITHUB_TOKEN is needed"
+ exit 1
fi
-# Download hub
-HUB_VERSION=${HUB_VERSION:-"2.5.1"}
-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" &>/dev/null
-export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
+if ! [ -x "$(command -v hub)" ]; then
+ echo "===== Download HUB ====="
+ HUB_VERSION=${HUB_VERSION:-"2.5.1"}
+ 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" &>/dev/null
+ export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
+fi
-echo "Looking up available labels"
-LABELS_FILE=/tmp/exclude_labels
-hub issue labels > $LABELS_FILE
+echo "===== Looking up available labels ====="
+LABELS_FILE=/tmp/labels
+hub issue labels >$LABELS_FILE
+echo "===== Categorizing issues ====="
+# This won't touch issues which already have at least one label assigned
for STATE in "open" "closed"; do
- for ISSUE in $(hub issue -f "%I %l%n" -s "$STATE" -d "$(date +%F -d '3 days ago')" | grep -v -f $LABELS_FILE); do
- echo "Processing $STATE issue no. $ISSUE"
- URL="https://api.github.com/repos/netdata/netdata/issues/$ISSUE"
- BODY="$(curl "${URL}" | jq .body 2>/dev/null)"
- case "${BODY}" in
- *"# Question summary"* ) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["question"]}' -X PATCH "${URL}" ;;
- *"# Bug report summary"* ) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["bug"]}' -X PATCH "${URL}" ;;
- * ) curl -H "Authorization: token $GITHUB_TOKEN" -d '{"labels":["needs triage"]}' -X PATCH "${URL}" ;;
- esac
- done
+ for ISSUE in $(hub issue -f "%I %l%n" -s "$STATE" -d "$(date +%F -d '1 day ago')" | grep -v -f $LABELS_FILE); do
+ echo "-------- Processing $STATE issue no. $ISSUE --------"
+ BODY="$(curl -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/netdata/netdata/issues/$ISSUE" 2>/dev/null | jq .body)"
+ case "${BODY}" in
+ *"# Question summary"*) new_labels "$ISSUE" "question" "no changelog" ;;
+ *"# Bug report summary"*) new_labels "$ISSUE" "needs triage" "bug" ;;
+ *"# Feature idea summary"*) new_labels "$ISSUE" "needs triage" "feature request" ;;
+ *) new_labels "$ISSUE" "needs triage" "no changelog" ;;
+ esac
+ done
+done
+
+# Change all 'area' labels assigned to PR saving non-area labels.
+echo "===== Categorizing PRs ====="
+NEW_LABELS=/tmp/new_labels
+for PR in $(hub pr list -s all -f "%I%n" -L 10); do
+ echo "----- Processing PR #$PR -----"
+ echo "" >$NEW_LABELS
+ NEW_SET=""
+ DIFF_URL="https://github.com/netdata/netdata/pull/$PR.diff"
+ for FILE in $(curl -L "${DIFF_URL}" 2>/dev/null | grep "diff --git a/" | cut -d' ' -f3 | sort | uniq); do
+ LABEL=""
+ case "${FILE}" in
+ *".md") AREA="docs" ;;
+ *"/collectors/python.d.plugin/"*) AREA="external/python" ;;
+ *"/collectors/charts.d.plugin/"*) AREA="external" ;;
+ *"/collectors/node.d.plugin/"*) AREA="external" ;;
+ *"/.travis"*) AREA="ci" ;;
+ *"/.github/*.md"*) AREA="docs" ;;
+ *"/.github/"*) AREA="ci" ;;
+ *"/build/"*) AREA="packaging" ;;
+ *"/contrib/"*) AREA="packaging" ;;
+ *"/diagrams/"*) AREA="docs" ;;
+ *"/installer/"*) AREA="packaging" ;;
+ *"/makeself/"*) AREA="packaging" ;;
+ *"/system/"*) AREA="packaging" ;;
+ *"/netdata-installer.sh"*) AREA="packaging" ;;
+ *) AREA=$(echo "$FILE" | cut -d'/' -f2) ;;
+ esac
+ LABEL="area/$AREA"
+ echo "Selecting $LABEL due to $FILE"
+ if grep "$LABEL" "$LABELS_FILE"; then
+ echo "$LABEL" >>$NEW_LABELS
+ if [[ $LABEL =~ "external" ]]; then
+ echo "area/collectors" >>$NEW_LABELS
+ fi
+ else
+ echo "-------- Label '$LABEL' not available --------"
+ fi
+ done
+ NEW_SET=$(sort $NEW_LABELS | uniq)
+ if [ ! -z "$NEW_SET" ]; then
+ PREV=$(curl -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/netdata/netdata/issues/$PR/labels" 2>/dev/null | jq '.[].name' | grep -v "area")
+ new_labels "$PR" ${NEW_SET} "${PREV[*]}"
+ fi
done
diff --git a/.travis/nightlies.sh b/.travis/nightlies.sh
new file mode 100755
index 000000000..fd133d08a
--- /dev/null
+++ b/.travis/nightlies.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+BAD_THING_HAPPENED=0
+
+if [ ! -f .gitignore ]; then
+ echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
+ exit 1
+fi
+
+export GIT_MAIL="pawel+bot@netdata.cloud"
+export GIT_USER="netdatabot"
+echo "--- Initialize git configuration ---"
+git config user.email "${GIT_MAIL}"
+git config user.name "${GIT_USER}"
+
+echo "--- UPDATE VERSION FILE ---"
+LAST_TAG=$(git describe --abbrev=0 --tags)
+NO_COMMITS=$(git rev-list "$LAST_TAG"..HEAD --count)
+if [ "$NO_COMMITS" == "$(rev <packaging/version | cut -d- -f 2 | rev)" ]; then
+ echo "Nothing changed since last nightly build"
+ exit 0
+fi
+echo "$LAST_TAG-$((NO_COMMITS + 1))-nightly" >packaging/version
+git add packaging/version || exit 1
+
+echo "--- GENERATE CHANGELOG ---"
+if .travis/generate_changelog.sh; then
+ git add CHANGELOG.md
+
+ echo "--- UPLOAD FILE CHANGES ---"
+ git commit -m '[ci skip] create nightly packages and update changelog'
+ git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
+else
+ git clean -xfd
+ BAD_THING_HAPPENED=1
+fi
+
+echo "--- BUILD & PUBLISH DOCKER IMAGES ---"
+export REPOSITORY="netdata/netdata"
+packaging/docker/build.sh || BAD_THING_HAPPENED=1
+
+echo "--- BUILD ARTIFACTS ---"
+.travis/create_artifacts.sh || BAD_THING_HAPPENED=1
+
+exit "${BAD_THING_HAPPENED}"
diff --git a/.travis/releaser.sh b/.travis/releaser.sh
index c184cc726..870dec52c 100755
--- a/.travis/releaser.sh
+++ b/.travis/releaser.sh
@@ -34,17 +34,41 @@ export GIT_USER="netdatabot"
echo "--- Initialize git configuration ---"
git config user.email "${GIT_MAIL}"
git config user.name "${GIT_USER}"
+git checkout master
+git pull
echo "---- FIGURING OUT TAGS ----"
# tagger.sh is sourced since we need environment variables it sets
#shellcheck source=/dev/null
source .travis/tagger.sh || exit 0
+# variable GIT_TAG is produced by tagger.sh script
+
+echo "---- UPDATE VERSION FILE ----"
+echo "$GIT_TAG" >packaging/version
+git add packaging/version
+
+echo "---- GENERATE CHANGELOG -----"
+./.travis/generate_changelog.sh
+git add CHANGELOG.md
+
+echo "---- COMMIT AND PUSH CHANGES ----"
+git commit -m "[ci skip] release $GIT_TAG"
+git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
+git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
+git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')" --tags
+# After those operations output of command `git describe` should be identical with a value of GIT_TAG
+
+if [[ $(git describe) =~ -rc* ]]; then
+ echo "This is a release candidate tag, exiting without artifact building"
+ exit 0
+fi
echo "---- CREATING TAGGED DOCKER CONTAINERS ----"
export REPOSITORY="netdata/netdata"
-./docker/build.sh
+./packaging/docker/build.sh
echo "---- CREATING RELEASE ARTIFACTS -----"
+# Artifacts are stored in `artifacts/` directory
./.travis/create_artifacts.sh
echo "---- CREATING RELEASE DRAFT WITH ASSETS -----"
@@ -63,12 +87,8 @@ if [ "${GIT_TAG}" != "$(git tag --points-at)" ]; then
echo "ERROR! Current commit is not tagged. Stopping release creation."
exit 1
fi
-if [ -z ${RC+x} ]; then
- hub release create --prerelease --draft -a "netdata-${GIT_TAG}.tar.gz" -a "netdata-${GIT_TAG}.gz.run" -a "sha256sums.txt" -m "${GIT_TAG}" "${GIT_TAG}"
-else
- hub release create --draft -a "netdata-${GIT_TAG}.tar.gz" -a "netdata-${GIT_TAG}.gz.run" -a "sha256sums.txt" -m "${GIT_TAG}" "${GIT_TAG}"
-fi
-
-# Changelog needs to be created AFTER new release to avoid problems with circular dependencies and wrong entries in changelog file
-echo "---- GENERATING CHANGELOG -----"
-./.travis/generate_changelog.sh
+hub release create --draft \
+ -a "artifacts/netdata-${GIT_TAG}.tar.gz" \
+ -a "artifacts/netdata-${GIT_TAG}.gz.run" \
+ -a "artifacts/sha256sums.txt" \
+ -m "${GIT_TAG}" "${GIT_TAG}"
diff --git a/.travis/tagger.sh b/.travis/tagger.sh
index b1907c347..e72c5721c 100755
--- a/.travis/tagger.sh
+++ b/.travis/tagger.sh
@@ -15,6 +15,8 @@
# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo
# - git-semver python package (pip install git-semver)
+# exported variables are needed by releaser.sh
+
set -e
if [ ! -f .gitignore ]; then
@@ -22,33 +24,19 @@ if [ ! -f .gitignore ]; then
exit 1
fi
-# Embed new version in files which need it.
-# This wouldn't be needed if we could use `git tag` everywhere.
-function embed_version {
- VERSION="$1"
- MAJOR=$(echo "$GIT_TAG" | cut -d . -f 1 | cut -d v -f 2)
- MINOR=$(echo "$GIT_TAG" | cut -d . -f 2)
- PATCH=$(echo "$GIT_TAG" | cut -d . -f 3 | cut -d '-' -f 1)
- sed -i "s/\\[VERSION_MAJOR\\], \\[.*\\]/\\[VERSION_MAJOR\\], \\[$MAJOR\\]/" configure.ac
- sed -i "s/\\[VERSION_MINOR\\], \\[.*\\]/\\[VERSION_MINOR\\], \\[$MINOR\\]/" configure.ac
- sed -i "s/\\[VERSION_PATCH\\], \\[.*\\]/\\[VERSION_PATCH\\], \\[$PATCH\\]/" configure.ac
- git add configure.ac
-}
-
# Figure out what will be new release candidate tag based only on previous ones.
# This assumes that RELEASES are in format of "v0.1.2" and prereleases (RCs) are using "v0.1.2-rc0"
-function release_candidate {
+function release_candidate() {
LAST_TAG=$(git semver)
if [[ $LAST_TAG =~ -rc* ]]; then
- LAST_RELEASE=$(echo "$LAST_TAG" | cut -d'-' -f 1)
+ VERSION=$(echo "$LAST_TAG" | cut -d'-' -f 1)
LAST_RC=$(echo "$LAST_TAG" | cut -d'c' -f 2)
RC=$((LAST_RC + 1))
else
- LAST_RELEASE=$LAST_TAG
+ VERSION="$(git semver --next-minor)"
RC=0
fi
- GIT_TAG="v$LAST_RELEASE-rc$RC"
- export GIT_TAG
+ GIT_TAG="v$VERSION-rc$RC"
}
# Check if current commit is tagged or not
@@ -62,20 +50,10 @@ if [ -z "${GIT_TAG}" ]; then
*"[netdata minor release]"*) GIT_TAG="v$(git semver --next-minor)" ;;
*"[netdata major release]"*) GIT_TAG="v$(git semver --next-major)" ;;
*"[netdata release candidate]"*) release_candidate ;;
- *) echo "Keyword not detected. Exiting..."; exit 1;;
+ *)
+ echo "Keyword not detected. Exiting..."
+ exit 0
+ ;;
esac
- # Tag it!
- if [ "$GIT_TAG" != "HEAD" ]; then
- echo "Assigning a new tag: $GIT_TAG"
- embed_version "$GIT_TAG"
- git commit -m "[ci skip] release $GIT_TAG"
- git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
- git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
- git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')" --tags
- fi
-else
- embed_version "$GIT_TAG"
- git commit -m "[ci skip] release $GIT_TAG"
- git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
fi
export GIT_TAG