@cryptotaxi247 / netdata-1 / commits / 792a0e805

Unify versioning (#5051)

* use 'git describe' * no need to embed version string anymore * fallback mechanism for package versioning

Paweł Krupa committed Jan 4, 2019 at 13:13 UTC 792a0e805454c79732c42caa72bc74aa489129e4
7 files changed +61 -81
.travis.yml
+6 -13
@@ -56,17 +56,15 @@ jobs:
56 depth: false
57
58 - stage: nightlies
59 - name: docker images
59 + name: Nightly build
60 + 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
61 install:
61 - - sudo apt update
62 + - sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot
63 - sudo apt install -y --only-upgrade docker-ce
64 - docker info
64 - script: "packaging/docker/build.sh"
65 - env: REPOSITORY="netdata/netdata"
66 - - name: tarball and self-extractor build
67 - 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
68 - install: sudo apt-get install -y gnupg libcap2-bin zlib1g-dev uuid-dev fakeroot
69 - script: ".travis/create_artifacts.sh"
65 + script: ".travis/nightlies.sh"
66 + git:
67 + depth: false
68 deploy:
69 provider: gcs
70 edge:
@@ -76,11 +74,6 @@ jobs:
74 bucket: "netdata-nightlies"
75 skip_cleanup: true
76 local_dir: "upload"
79 - - name: changelog generation
80 - script: ".travis/generate_changelog.sh"
81 - env: COMMIT_AND_PUSH=1
82 - git:
83 - depth: false
77
78 notifications:
79 webhooks: https://app.fossa.io/hooks/travisci
.travis/generate_changelog.sh
-11
@@ -7,7 +7,6 @@ if [ ! -f .gitignore ]; then
7 exit 1
8 fi
9
10 -COMMIT_AND_PUSH=${COMMIT_AND_PUSH:-0}
10 ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
11 PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
12 GIT_MAIL=${GIT_MAIL:-"pawel+bot@netdata.cloud"}
@@ -19,10 +18,6 @@ else
18 OPTS="--future-release ${GIT_TAG}"
19 fi
20
22 -echo "--- Initialize git configuration ---"
23 -git config user.email "${GIT_MAIL}"
24 -git config user.name "${GIT_USER}"
25 -
21 echo "--- Creating changelog ---"
22 git checkout master
23 git pull
@@ -36,9 +31,3 @@ docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest
31 --exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
32 --no-compare-link ${OPTS}
33
39 -echo "--- Uploading changelog ---"
40 -git add CHANGELOG.md
41 -if [ "${COMMIT_AND_PUSH}" == "1" ]; then
42 - git commit -m '[ci skip] Automatic changelog update' || exit 0
43 - git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
44 -fi
.travis/nightlies.sh new
+35
@@ -0,0 +1,35 @@
1 +#!/bin/bash
2 +
3 +set -e
4 +
5 +if [ ! -f .gitignore ]; then
6 + echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
7 + exit 1
8 +fi
9 +
10 +export GIT_MAIL="pawel+bot@netdata.cloud"
11 +export GIT_USER="netdatabot"
12 +echo "--- Initialize git configuration ---"
13 +git config user.email "${GIT_MAIL}"
14 +git config user.name "${GIT_USER}"
15 +
16 +echo "--- UPDATE VERSION FILE ---"
17 +LAST_TAG=$(git describe --abbrev=0 --tags)
18 +NO_COMMITS=$(git rev-list "$LAST_TAG"..HEAD --count)
19 +echo "$LAST_TAG-$((NO_COMMITS + 1))-nightly" >packaging/version
20 +git add packaging/version
21 +
22 +echo "---- GENERATE CHANGELOG -----"
23 +.travis/generate_changelog.sh
24 +git add CHANGELOG.md
25 +
26 +echo "---- UPLOAD FILE CHANGES ----"
27 +git commit -m '[ci skip] create nightly packages and update changelog'
28 +git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e 's/^https:\/\///')"
29 +
30 +echo "---- BUILD & PUBLISH DOCKER IMAGES ----"
31 +export REPOSITORY="netdata/netdata"
32 +packaging/docker/build.sh
33 +
34 +echo "---- BUILD ARTIFACTS ----"
35 +.travis/create_artifacts.sh
.travis/releaser.sh
+6 -1
@@ -42,8 +42,13 @@ echo "---- FIGURING OUT TAGS ----"
42 #shellcheck source=/dev/null
43 source .travis/tagger.sh || exit 0
44
45 -echo "---- GENERATING CHANGELOG -----"
45 +echo "---- UPDATE VERSION FILE ----"
46 +echo "$GIT_TAG" >packaging/version
47 +git add packaging/version
48 +
49 +echo "---- GENERATE CHANGELOG -----"
50 ./.travis/generate_changelog.sh
51 +git add CHANGELOG.md
52
53 echo "---- COMMIT AND PUSH CHANGES ----"
54 git commit -m "[ci skip] release $GIT_TAG"
.travis/tagger.sh
-14
@@ -24,19 +24,6 @@ if [ ! -f .gitignore ]; then
24 exit 1
25 fi
26
27 -# Embed new version in files which need it.
28 -# This wouldn't be needed if we could use `git tag` everywhere.
29 -function embed_version() {
30 - VERSION="$1"
31 - MAJOR=$(echo "$GIT_TAG" | cut -d . -f 1 | cut -d v -f 2)
32 - MINOR=$(echo "$GIT_TAG" | cut -d . -f 2)
33 - PATCH=$(echo "$GIT_TAG" | cut -d . -f 3 | cut -d '-' -f 1)
34 - sed -i "s/\\[VERSION_MAJOR\\], \\[.*\\]/\\[VERSION_MAJOR\\], \\[$MAJOR\\]/" configure.ac
35 - sed -i "s/\\[VERSION_MINOR\\], \\[.*\\]/\\[VERSION_MINOR\\], \\[$MINOR\\]/" configure.ac
36 - sed -i "s/\\[VERSION_PATCH\\], \\[.*\\]/\\[VERSION_PATCH\\], \\[$PATCH\\]/" configure.ac
37 - git add configure.ac
38 -}
39 -
27 # Figure out what will be new release candidate tag based only on previous ones.
28 # This assumes that RELEASES are in format of "v0.1.2" and prereleases (RCs) are using "v0.1.2-rc0"
29 function release_candidate() {
@@ -71,5 +58,4 @@ if [ -z "${GIT_TAG}" ]; then
58 ;;
59 esac
60 fi
74 -embed_version "$GIT_TAG"
61 export GIT_TAG
configure.ac
+4 -9
@@ -4,24 +4,19 @@
4 #
5 AC_PREREQ(2.60)
6
7 -define([VERSION_MAJOR], [1])
8 -define([VERSION_MINOR], [12])
9 -define([VERSION_FIX], [1])
10 -define([VERSION_NUMBER], VERSION_MAJOR[.]VERSION_MINOR[.]VERSION_FIX)
11 -
7 # We do not use m4_esyscmd_s to support older autoconf.
13 -define([VERSION_STRING], m4_esyscmd(git describe 2>/dev/null | sed 's/^v//' | tr -d '\n'))
14 -m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_NUMBER)])
8 +define([VERSION_STRING], m4_esyscmd([git describe 2>/dev/null | tr -d '\n']))
9 +define([VERSION_FROM_FILE], m4_esyscmd([cat packaging/version | tr -d '\n']))
10 +m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_FROM_FILE)])
11
12 AC_INIT([netdata], VERSION_STRING[])
13
14 AM_MAINTAINER_MODE([disable])
15 if test x"$USE_MAINTAINER_MODE" = xyes; then
16 AC_MSG_NOTICE(***************** MAINTAINER MODE *****************)
21 -PACKAGE_BUILT_DATE=$(date '+%d %b %Y')
17 fi
18
24 -PACKAGE_RPM_VERSION="VERSION_NUMBER"
19 +PACKAGE_RPM_VERSION="VERSION_STRING"
20 AC_SUBST([PACKAGE_RPM_VERSION])
21
22 # -----------------------------------------------------------------------------
packaging/makeself/jobs/99-makeself.install.sh
+10 -33
@@ -8,35 +8,16 @@ run cd "${NETDATA_SOURCE_PATH}" || exit 1
8 # -----------------------------------------------------------------------------
9 # find the netdata version
10
11 -NOWNER="unknown"
12 -ORIGIN="$(git config --get remote.origin.url || echo "unknown")"
13 -if [[ "${ORIGIN}" =~ ^git@github.com:.*/netdata.*$ ]]
14 - then
15 - NOWNER="${ORIGIN/git@github.com:/}"
16 - NOWNER="$( echo ${NOWNER} | cut -d '/' -f 1 )"
17 -
18 -elif [[ "${ORIGIN}" =~ ^https://github.com/.*/netdata.*$ ]]
19 - then
20 - NOWNER="${ORIGIN/https:\/\/github.com\//}"
21 - NOWNER="$( echo ${NOWNER} | cut -d '/' -f 1 )"
11 +VERSION="$(git describe 2>/dev/null)"
12 +if [ -z "${VERSION}" ]; then
13 + VERSION=$(cat packaging/version)
14 fi
15
24 -# make sure it does not have any slashes in it
25 -NOWNER="${NOWNER//\//_}"
26 -
27 -if [ "${NOWNER}" = "netdata" ]
28 - then
29 - NOWNER=
30 -else
31 - NOWNER="-${NOWNER}"
16 +if [ "${VERSION}" == "" ]; then
17 + echo >&2 "Cannot find version number. Create makeself executable from source code with git tree structure."
18 + exit 1
19 fi
20
34 -VERSION="$(git describe || echo "undefined")"
35 -[ -z "${VERSION}" ] && VERSION="undefined"
36 -
37 -FILE_VERSION="${VERSION}-$(uname -m)-$(date +"%Y%m%d-%H%M%S")${NOWNER}"
38 -
39 -
21 # -----------------------------------------------------------------------------
22 # copy the files needed by makeself installation
23
@@ -84,7 +65,7 @@ run rm "${NETDATA_INSTALL_PATH}/sbin" \
65 # -----------------------------------------------------------------------------
66 # create the makeself archive
67
87 -run sed "s|NETDATA_VERSION|${FILE_VERSION}|g" <"${NETDATA_MAKESELF_PATH}/makeself.lsm" >"${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
68 +run sed "s|NETDATA_VERSION|${VERSION}|g" <"${NETDATA_MAKESELF_PATH}/makeself.lsm" >"${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
69
70 run "${NETDATA_MAKESELF_PATH}/makeself.sh" \
71 --gzip \
@@ -107,11 +88,7 @@ run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
88 # -----------------------------------------------------------------------------
89 # copy it to the netdata build dir
90
110 -FILE="netdata-${FILE_VERSION}.gz.run"
111 -
112 -run cp "${NETDATA_INSTALL_PATH}.gz.run" "${FILE}"
113 -echo >&2 "Self-extracting installer copied to '${FILE}'"
91 +FILE="netdata-${VERSION}.gz.run"
92
115 -[ -f netdata-latest.gz.run ] && rm netdata-latest.gz.run
116 -run ln -s "${FILE}" netdata-latest.gz.run
117 -echo >&2 "Self-extracting installer linked to 'netdata-latest.gz.run'"
93 +run mv "${NETDATA_INSTALL_PATH}.gz.run" "${FILE}"
94 +echo >&2 "Self-extracting installer moved to '${FILE}'"