Add option to create release candidates (#4706)
[netdata patch release]
Paweł Krupa committed
Nov 22, 2018 at 20:11 UTC
035ba52862c9667739c0f461bf2a2b39ed677ee2
3 files changed
+64
-30
.travis/README.md
+34
-26
@@ -29,40 +29,43 @@ installations of netdata. Jobs are run on following operating systems:
29
- CentOS 7 (containerized)
30
- alpine (containerized)
31
32
-### Release
32
+### Packaging
33
34
This stage is executed only on "master" brach and allows us to create a new tag just looking at git commit message.
35
-It also has an option to automatically generate changelog based on GitHub labels and sync it with GitHub release.
36
-For the sake of simplicity and to use travis features this stage cannot be integrated with next stage.
37
-
38
-Releases are generated by searching for a keyword in last commit message. Keywords are:
39
- - [patch] or [fix] to bump patch number
40
- - [minor], [feature] or [feat] to bump minor number
41
- - [major] or [breaking change] to bump major number
42
-All keywords MUST be surrounded with square braces.
43
-Alternative is to push a tag to master branch.
44
-
45
-### Packaging
35
+It executes one script called `releaser.sh` which is responsible for creating a release on GitHub by using
36
+[hub](https://github.com/github/hub). This script is also executing other scripts which can also be used in other
37
+CI jobs:
38
+ - `tagger.sh`
39
+ - `generate_changelog.sh`
40
+ - `build.sh`
41
+ - `create_artifacts.sh`
42
47
-This stage is executed only on "master" branch and it is separated into 3 jobs:
48
- - Update Changelog/Create release
49
- - Nightly tarball and self-extractor build
50
- - Nightly docker images
43
+Alternatively new release can be also created by pushing new tag to master branch.
44
52
-##### Update Changelog/Create release
45
+##### tagger.sh
46
54
-This job is running one script called `releaser.sh`, which is responsible for a couple of things. First of all it
55
-automatically updates our CHANGELOG.md file based on GitHub features (mostly labels and pull requests). Apart from
56
-that it can also create a new git tag and a github draft release connected to that tag.
57
-Releases are generated by searching for a keyword in last commit message. Keywords are:
47
+Script responsible to find out what will be the next tag based on a keyword in last commit message. Keywords are:
48
- `[netdata patch release]` to bump patch number
49
- `[netdata minor release]` to bump minor number
50
- `[netdata major release]` to bump major number
51
+ - `[netdata release candidate]` to create a new release candidate (appends or modifies suffix `-rcX` of previous tag)
52
All keywords MUST be surrounded with square brackets.
53
+Tag is then stored in `GIT_TAG` variable.
54
63
-Alternatively new release can be also created by pushing new tag to master branch.
55
+##### generate_changelog.sh
56
65
-##### Nightly tarball and self-extractor build AND Nightly docker images
57
+Automatic changelog generator which updates our CHANGELOG.md file based on GitHub features (mostly labels and pull
58
+requests). Internally it uses
59
+[github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator) and more
60
+information can be found on that project site.
61
+
62
+##### build.sh and create_artifacts.sh
63
+
64
+Scripts used to build new container images and provide release artifacts (tar.gz and makeself archives)
65
+
66
+### Nightlies
67
+
68
+##### Tarball and self-extractor build AND Nightly docker images
69
70
As names might suggest those two jobs are responsible for nightly netdata package creation and are run every day (in
71
cron). Combined they produce:
@@ -70,11 +73,16 @@ cron). Combined they produce:
73
- tar.gz archive (soon to be removed)
74
- self-extracting package
75
73
-Currently "Nightly tarball and self-extractor build" is using old firehol script and it is planed to be replaced with
74
-new design.
76
+This is achieved by running 2 scripts described earlier:
77
+ - `create_artifacts.sh`
78
+ - `build.sh`
79
76
-##### Nightly changelog generation
80
+##### Changelog generation
81
82
This job is responsible for regenerating changelog every day by executing `generate_changelog.sh` script. This is done
83
only once a day due to github rate limiter.
84
85
+##### Labeler
86
+
87
+Once a day we are doing automatic label assignment by executing `labeler.sh`. This script is a temporary workaround until
88
+we start using GitHub Actions. For more information what it is currently doing go to its code.
.travis/releaser.sh
+12
-3
@@ -21,7 +21,6 @@
21
# Requirements:
22
# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo
23
# - docker
24
-# - git-semver python package (pip install git-semver)
24
25
set -e
26
@@ -37,7 +36,9 @@ git config user.email "${GIT_MAIL}"
36
git config user.name "${GIT_USER}"
37
38
echo "---- FIGURING OUT TAGS ----"
40
-./.travis/tagger.sh || exit 0
39
+# tagger.sh is sourced since we need environment variables it sets
40
+#shellcheck source=/dev/null
41
+source .travis/tagger.sh || exit 0
42
43
echo "---- GENERATING CHANGELOG -----"
44
./.travis/generate_changelog.sh
@@ -57,4 +58,12 @@ tar -C /tmp -xvf "/tmp/hub-linux-amd64-${HUB_VERSION}.tgz"
58
export PATH=$PATH:"/tmp/hub-linux-amd64-${HUB_VERSION}/bin"
59
60
# Create a release draft
60
-hub release create --draft -a "netdata-${GIT_TAG}.tar.gz" -a "netdata-${GIT_TAG}.gz.run" -a "sha256sums.txt" -m "${GIT_TAG}" "${GIT_TAG}"
61
+if [ -z ${GIT_TAG+x} ]; then
62
+ echo "Variable GIT_TAG is not set. Something went terribly wrong! Exiting."
63
+ exit 1
64
+fi
65
+if [ -z ${RC+x} ]; then
66
+ 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}"
67
+else
68
+ hub release create --draft -a "netdata-${GIT_TAG}.tar.gz" -a "netdata-${GIT_TAG}.gz.run" -a "sha256sums.txt" -m "${GIT_TAG}" "${GIT_TAG}"
69
+fi
.travis/tagger.sh
+18
-1
@@ -35,6 +35,22 @@ function embed_version {
35
git add configure.ac
36
}
37
38
+# Figure out what will be new release candidate tag based only on previous ones.
39
+# This assumes that RELEASES are in format of "v0.1.2" and prereleases (RCs) are using "v0.1.2-rc0"
40
+function release_candidate {
41
+ LAST_TAG=$(git semver)
42
+ if [[ $LAST_TAG =~ -rc* ]]; then
43
+ LAST_RELEASE=$(echo "$LAST_TAG" | cut -d'-' -f 1)
44
+ LAST_RC=$(echo "$LAST_TAG" | cut -d'c' -f 2)
45
+ RC=$((LAST_RC + 1))
46
+ else
47
+ LAST_RELEASE=$LAST_TAG
48
+ RC=0
49
+ fi
50
+ GIT_TAG="v$LAST_RELEASE-rc$RC"
51
+ export GIT_TAG
52
+}
53
+
54
# Check if current commit is tagged or not
55
GIT_TAG=$(git tag --points-at)
56
if [ -z "${GIT_TAG}" ]; then
@@ -45,9 +61,9 @@ if [ -z "${GIT_TAG}" ]; then
61
*"[netdata patch release]"*) GIT_TAG="v$(git semver --next-patch)" ;;
62
*"[netdata minor release]"*) GIT_TAG="v$(git semver --next-minor)" ;;
63
*"[netdata major release]"*) GIT_TAG="v$(git semver --next-major)" ;;
64
+ *"[netdata release candidate]"*) release_candidate ;;
65
*) echo "Keyword not detected. Exiting..."; exit 1;;
66
esac
50
-
67
# Tag it!
68
if [ "$GIT_TAG" != "HEAD" ]; then
69
echo "Assigning a new tag: $GIT_TAG"
@@ -62,3 +78,4 @@ else
78
git commit -m "[ci skip] release $GIT_TAG"
79
git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
80
fi
81
+export GIT_TAG