summaryrefslogtreecommitdiffstats
path: root/.travis/trigger_package_generation.sh
blob: b58832cf4e1e819a84e1e002eae2742948168121 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
#
# Trigger .RPM and .DEB package generation processes
#
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
#
# Author: Pavlos Emm. Katsoulakis <paul@netdata.cloud>
set -e
WAIT_TIME=15
BUILD_NIGHTLY="$1"

commit_change() {
	local ARCH="$1"
	local PKG="$2"
	local GIT_MAIL="bot@netdata.cloud"
	local GIT_USER="netdatabot"

	echo "---- Committing ${ARCH} .${PKG} package generation ----"
	git commit --allow-empty --author "${GIT_USER} <${GIT_MAIL}>" -m "[Package ${ARCH} ${PKG}]${BUILD_NIGHTLY} Package build process trigger"
}

push_change() {

	echo "---- Push changes to repository ----"
	git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
}

# If we are not in netdata git repo, at the top level directory, fail
TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
CWD=$(git rev-parse --show-cdup || echo "")
if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
    echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
    echo "Changelog generation process aborted"
    exit 1
fi

echo "--- Initialize git configuration ---"
git checkout master
git fetch --all
git pull

commit_change "amd64" "DEB"
push_change

echo "---- Waiting for ${WAIT_TIME} seconds before triggering next process ----"
sleep "${WAIT_TIME}"

commit_change "i386" "DEB"
push_change

echo "---- Waiting for ${WAIT_TIME} seconds before triggering next process ----"
sleep "${WAIT_TIME}"

commit_change "amd64" "RPM"
push_change

echo "---- Done! ----"