new releaser (#4526)
Paweł Krupa committed
Oct 31, 2018 at 17:02 UTC
97187d52dba058f66cb82dc60a2062e1122e9486
4 files changed
+82
-70
.gitignore
+1
@@ -30,6 +30,7 @@ ltmain.sh
30
missing
31
stamp-h1
32
netdata.spec
33
+sha256sums.txt
34
35
# netdata binaries
36
netdata
.travis.yml
+1
-14
@@ -61,26 +61,13 @@ jobs:
61
62
- stage: "release"
63
name: "Create release"
64
+ install: sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot
65
script: .travis/releaser.sh
66
67
- stage: "package"
68
name: "Archive and self-extractor"
69
install: sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot
70
script: .travis/create_artifacts.sh
70
- deploy:
71
- - provider: releases
72
- draft: true
73
- api_key:
74
- secure: hbyuWsTshQ8Ixrgla2J6xtBNhQ1OjjaQ7hUEteclHrlx6i8B1ughCdhC3bYE1VGKClmq9mUvuZxcPGDDUaMBoLYTNaFx93IWorlrB29mpeNPd3b+DZqOePBYqU6NCA7PQccEUBkXJrGS44ZNg+pHFVCHMBe99+5u1Dfx/IJW0ojOb9XOfde6p5aL7syYWYXR/Ov/K40QAgpEDhAKUY4T1D/Yyk2ucdh6QsM00aq51F3D1SxIcFXcnBpacD3iGdkd3fM+c9PLMtq47mOicRjJsDnXYV58/upzmR9OPJYBbOPtNy0UKRl3f81cm5O4X3wcUBUMV4AQew8udy06TlWu2SQipGeh0RPDspRrBIqKhPJGX+h4Zyw/9iGvsDPetQqgoAsPqcruKGqNjC538LXr/fi8mur35VcKhmxi6gH7SNbs7TXfVLnrvNGgr6KCcKoLvFMxsJW1fQObVOq2mO+MwH6wQbqfRIo8btu6WVrzI4cYkZomny2i4D5YWVfTYEJ+BSTZCZ/l/RvxEYPUPFGyASxZ1OVCYA2in1JYdiPPMwK4gH66nYJG+ZDeTK5JUlXZAELZSRcDzecOAbi5zS/C3XXiGaHOXZBXjI0Gsw4kDaZn0xGUIzBFvMoSf1SMw5CuJ1kbSIzi4VGU1v85JaCB4znQ4pA4Yvw0/5l/q/B08aI=
75
- skip_cleanup: true
76
- file_glob: true
77
- file:
78
- - "netdata*.tar.gz*"
79
- - "netdata*.gz.run*"
80
- - "sha256sums.txt"
81
- on:
82
- repo: netdata/netdata
83
- tags: true
71
- name: "Docker images"
72
install: sudo apt update -y && sudo apt install -y --only-upgrade docker-ce && docker info
73
script: docker/build.sh
.travis/README.md
+8
-13
@@ -2,7 +2,7 @@
2
3
## Variables needed by travis
4
5
-- GH_TOKEN - GitHub token with push access to repository
5
+- GITHUB_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
8
- encrypted_decb6f6387c4_key - Something to do with package releasing (soon to be deprecated)
@@ -12,18 +12,6 @@
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
-
15
### Test
16
17
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
34
It also has an option to automatically generate changelog based on GitHub labels and sync it with GitHub release.
35
For the sake of simplicity and to use travis features this stage cannot be integrated with next stage.
36
37
+Releases are generated by searching for a keyword in last commit message. Keywords are:
38
+ - [patch] or [fix] to bump patch number
39
+ - [minor], [feature] or [feat] to bump minor number
40
+ - [major] or [breaking change] to bump major number
41
+All keywords MUST be surrounded with square braces.
42
+Alternative is to push a tag to master branch.
43
+
44
### Packages
45
46
As a name might suggest, this stage is responsible for creating netdata packages such as:
.travis/releaser.sh
+72
-43
@@ -8,7 +8,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
11
+# - create draft of GitHub releases by using https://github.com/github/hub
12
#
13
# Tags are generated by searching for a keyword in last commit message. Keywords are:
14
# - [patch] or [fix] to bump patch number
@@ -19,10 +19,9 @@
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
22
+# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo
23
# - docker
24
# - git-semver python package (pip install git-semver)
25
-#
25
26
if [ ! -f .gitignore ]
27
then
@@ -30,55 +29,85 @@ then
29
exit 1
30
fi
31
33
-# Exit when latest commit is tagged
34
-[[ $(git tag --points-at) ]] && exit 0
35
-
32
+echo "---- INITIALIZING CONFIGURATION -----"
33
# Some basic variables
34
GIT_MAIL="pawel+bot@netdata.cloud"
35
GIT_USER="netdatabot"
39
-# ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
40
-# PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
36
+ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
37
+PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
38
+HUB_VERSION=${HUB_VERSION:-"2.5.1"}
39
40
# Git config
43
-git config --global user.email "${GIT_MAIL}"
44
-git config --global user.name "${GIT_USER}"
41
+git config user.email "${GIT_MAIL}"
42
+git config user.name "${GIT_USER}"
43
GIT_URL=$(git config --get remote.origin.url)
44
GIT_URL=${GIT_URL#*//}
45
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
46
+echo "---- FIGURING OUT TAGS-----"
47
+# Check if current commit is tagged or not
48
+GIT_TAG=$(git tag --points-at)
49
+if [ -z "${GIT_TAG}" ]; then
50
+ # Figure out next tag based on commit message
51
+ GIT_TAG=HEAD
52
+ echo "Last commit message: $TRAVIS_COMMIT_MESSAGE"
53
+ case "${TRAVIS_COMMIT_MESSAGE}" in
54
+ *"[patch]"*|*"[fix]"* ) GIT_TAG="v$(git semver --next-patch)" ;;
55
+ *"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG="v$(git semver --next-minor)" ;;
56
+ *"[major]"*|*"[breaking change]"* ) GIT_TAG="v$(git semver --next-major)" ;;
57
+ *) echo "Keyword not detected. Doing nothing" ;;
58
+ esac
59
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
60
+ # Tag it!
61
+ if [ "$GIT_TAG" != "HEAD" ]; then
62
+ echo "Assigning a new tag: $GIT_TAG"
63
+ git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
64
+ git push "https://${GITHUB_TOKEN}:@${GIT_URL}" --tags || exit 0 # exits if tag exists
65
+ fi
66
fi
67
66
-## Generate CHANGELOG.md
67
-#git checkout master
68
-#git pull
68
+# 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.
69
+# This condition can be triggered by a cron job and it shouldn't create a release but might be still useful for changelog generation.
70
+
71
+echo "---- CREATING CHANGELOG -----"
72
+#PREV_TAG=$(git describe --abbrev=0 "${GIT_TAG}"^)
73
+git checkout master
74
+git pull
75
#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
76
+docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \
77
+ --user "${ORGANIZATION}" \
78
+ --project "${PROJECT}" \
79
+ --token "${GITHUB_TOKEN}" \
80
+ --since-tag "v1.10.0" \
81
+ --unreleased-label "**Next release**" \
82
+ --no-compare-link \
83
+ --exclude-labels duplicate,question,invalid,wontfix,discussion,documentation
84
+
85
+echo "---- UPLOADING CHANGELOG -----"
86
+git add CHANGELOG.md
87
+git commit -m '[ci skip] Automatic changelog update'
88
+git push "https://${GITHUB_TOKEN}:@${GIT_URL}" || exit 0 # Exit if changlog was already uploaded
89
+
90
+if [ "${GIT_TAG}" == "HEAD" ]; then
91
+ echo "Not creating a release since neither of two conditions was met:"
92
+ echo " - keyword in commit message"
93
+ echo " - commit is tagged"
94
+ exit 0
95
+fi
96
+
97
+echo "---- CREATING RELEASE ARTIFACTS -----"
98
+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);'
99
+
100
+./makeself/build-x86_64-static.sh
101
+make dist
102
+ln -s netdata-latest.gz.run "netdata-${GIT_TAG}.gz.run"
103
+ln -s netdata-*.tar.gz "netdata-${GIT_TAG}.tar.gz"
104
+sha256sum -b "netdata-${GIT_TAG}.gz.run" "netdata-${GIT_TAG}.tar.gz" > "sha256sums.txt"
105
+
106
+echo "---- CREATING RELEASE DRAFT WITH ASSETS -----"
107
+# Download hub
108
+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"
109
+tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz"
110
+export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
111
+
112
+# Create a release draft
113
+hub release create --draft -a "netdata-${GIT_TAG}.tar.gz" -a "netdata-${GIT_TAG}.gz.run" -a "sha256sums.txt" -m "${GIT_TAG}" "${GIT_TAG}"