Skip to content

Commit ae4bb02

Browse files
paulkatsoulakiscakrit
authored andcommitted
netdata/ci: nits and fixes around package release workflow (netdata#6914)
* netdata/packaging: bring el/6 first, because this appears on all cases. Otherwise travis craps out the steps * netdata/ci: Attempt to sanitise workflow for master branch commits 1) Rename Packaging for release, now named: Support activities on main branch 2) Adjust instruction messages to reflect more realistically the activities 3) Put labeler first on the stage, since this will always run 4) Make changelog and tag for release conditionally run, so that it does not confuse people * netdata/ci: Sanitise workflow for release more (explained below) We need to clean up tagging logic more and in order to do this we need to bring tagger logic to travis.yml Then we have the complete control of tagging and triggering for changelog generation in travis. To mitigate this, we need to: 1) make tagger script a lirbary. Keep the tagging logic in a method and remove the things needed when it was an executable (checks, executions etc) 2) make travis handle GIT_TAG checking and setting at the beginning. We need this outside of any conditionals so that we have GIT_TAG result available inside the steps 3) COMMIT_TAG_POINTS_AT can now become GIT_TAG, since this is what we actually wanted. We just named differently before to avoid any weird conflicts 4) make changelog generation for release to NOT source tagger any more. Also make it fail in case GIT_TAG is not there, we wont run the script if git tag not in place so that should be error if it happens 5) Rename .travis/generate_changelog_for_release.sh -> .travis/create_changelog_for_release.sh 6) Rename .travis/generate_changelog_and_tag_release.sh -> .travis/generate_changelog_for_release.sh * netdata/ci: reinstate filename here. we basically do the git tag operation here still * netdata/ci: simplify more the changelog generation process 1) Rename create_changelog_for_release.sh -> create_changelog.sh 2) Add comments and the standard path checks in create_changelog.sh 3) Do some minor changes to help diff with nightlies changelog (no functional change though, primarily messages and move flags lower) 4) Inside generate_changelog_for_nightlies.sh, use create_changelog.sh and remove code related to create changelog process 5) in nightlies.sh, use standard shebang adn fix some messages Note: might follow up with more changes, this is just a first batch * netdata/packaging: reinstate accidentally removed OPTS from other iterationns (different engineer)
1 parent 2ba4d7c commit ae4bb02

6 files changed

+75
-102
lines changed

Diff for: .travis.yml

+18-14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ install:
3131
- if [[ "${TRAVIS_COMMIT_MESSAGE}" = *"[Build latest]"* ]]; then export DEPLOY_REPO="netdata-edge"; fi;
3232
- export PACKAGE_CLOUD_RETENTION_DAYS=30
3333
- if [ ! "${TRAVIS_REPO_SLUG}" = "netdata/netdata" ]; then export DEPLOY_REPO="netdata-devel"; fi;
34+
# These are release-related artifacts and have to be evaluated before we start doing conditional checks inside stages
35+
- source ".travis/tagger.sh"
36+
- export GIT_TAG="$(git tag --points-at)"
37+
- if [[ -z "${GIT_TAG}" ]]; then echo "Running set tag for release" && set_tag_for_release; fi;
3438

3539

3640

@@ -58,7 +62,7 @@ stages:
5862
if: branch = master AND type = cron
5963

6064
# Scheduled releases
61-
- name: Packaging for release
65+
- name: Support activities on main branch
6266
if: branch = master AND type != pull_request AND type != cron
6367

6468
- name: Publish for release
@@ -240,22 +244,22 @@ jobs:
240244

241245

242246

243-
- stage: Packaging for release
247+
- stage: Support activities on main branch
248+
name: Run labeler on github issues
249+
script: .travis/labeler.sh # labeler should be replaced with GitHub Actions when they hit GA
244250

245-
name: Generate changelog and TAG the release (only on special commit msg)
246-
before_script: post_message "TRAVIS_MESSAGE" "Packaging step for release initiated" "${NOTIF_CHANNEL}"
251+
- name: Generate changelog for release (only on special and tagged commit msg)
252+
before_script: post_message "TRAVIS_MESSAGE" "Support activities on main branch initiated" "${NOTIF_CHANNEL}"
247253
script:
248254
- echo "GIT Branch:" && git branch
249255
- echo "Last commit:" && git log -1
250256
- echo "GIT Describe:" && git describe
251257
- echo "packaging/version:" && cat packaging/version
252258
- .travis/generate_changelog_and_tag_release.sh
253-
after_failure: post_message "TRAVIS_MESSAGE" "<!here> Packaging for release failed"
259+
after_failure: post_message "TRAVIS_MESSAGE" "<!here> Changelog generation and tag of release, failed"
254260
git:
255261
depth: false
256-
257-
- name: Run labeler on github issues
258-
script: .travis/labeler.sh # labeler should be replaced with GitHub Actions when they hit GA
262+
if: commit_message =~ /\[netdata (release candidate|(major|minor|patch) release)\]/ AND tag !~ /(-rc)/ OR (env(GIT_TAG) IS present AND NOT env(GIT_TAG) IS blank)
259263

260264

261265

@@ -411,19 +415,19 @@ jobs:
411415
- if [ -n "${BUILDER_NAME}" ]; then rm -rf /home/${BUILDER_NAME}/* && echo "Cleared /home/${BUILDER_NAME} directory" || echo "Failed to clean /home/${BUILDER_NAME} directory"; fi;
412416
- if [ -d "${PACKAGES_DIRECTORY}" ]; then rm -rf "${PACKAGES_DIRECTORY}"; fi;
413417

414-
name: "Build & Publish RPM package for Enterprise Linux 7"
418+
name: "Build & Publish RPM package for Enterprise Linux 6"
415419
<<: *RPM_TEMPLATE
416-
if: commit_message =~ /\[Package (amd64|arm64) RPM( Enterprise Linux)?\]/
420+
if: commit_message =~ /\[Package (amd64|arm64|i386) RPM( Enterprise Linux)?\]/
417421
env:
418-
- BUILDER_NAME="builder" BUILD_DISTRO="centos" BUILD_RELEASE="7" BUILD_STRING="el/7"
422+
- BUILDER_NAME="builder" BUILD_DISTRO="centos" BUILD_RELEASE="6" BUILD_STRING="el/6"
419423
- PACKAGE_TYPE="rpm" REPO_TOOL="yum"
420424
- ALLOW_SOFT_FAILURE_HERE=true
421425

422-
- name: "Build & Publish RPM package for Enterprise Linux 6"
426+
- name: "Build & Publish RPM package for Enterprise Linux 7"
423427
<<: *RPM_TEMPLATE
424-
if: commit_message =~ /\[Package (amd64|arm64|i386) RPM( Enterprise Linux)?\]/
428+
if: commit_message =~ /\[Package (amd64|arm64) RPM( Enterprise Linux)?\]/
425429
env:
426-
- BUILDER_NAME="builder" BUILD_DISTRO="centos" BUILD_RELEASE="6" BUILD_STRING="el/6"
430+
- BUILDER_NAME="builder" BUILD_DISTRO="centos" BUILD_RELEASE="7" BUILD_STRING="el/7"
427431
- PACKAGE_TYPE="rpm" REPO_TOOL="yum"
428432
- ALLOW_SOFT_FAILURE_HERE=true
429433

Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1-
#!/bin/bash
2-
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
4+
#
5+
# Author : Pavlos Emm. Katsoulakis ([email protected])
36
set -e
47

5-
if [ ! -f .gitignore ]; then
6-
echo "Run as ./travis/$(basename "$0") from top level directory of git repository"
7-
exit 1
8+
# If we are not in netdata git repo, at the top level directory, fail
9+
TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
10+
CWD=$(git rev-parse --show-cdup || echo "")
11+
if [ -n "$CWD" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
12+
echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
13+
echo "Changelog creation aborted"
14+
exit 1
815
fi
916

1017
ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
1118
PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
1219
GIT_MAIL=${GIT_MAIL:-"[email protected]"}
1320
GIT_USER=${GIT_USER:-"netdatabot"}
21+
1422
if [ -z ${GIT_TAG+x} ]; then
1523
OPTS=""
1624
else
1725
OPTS="--future-release ${GIT_TAG}"
1826
fi
1927

2028
if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
21-
echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing else to do"
29+
echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing else to do here"
2230
exit 0
2331
fi
2432

@@ -31,8 +39,8 @@ docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest
3139
--project "${PROJECT}" \
3240
--token "${GITHUB_TOKEN}" \
3341
--since-tag "v1.10.0" \
34-
--no-issues \
3542
--unreleased-label "**Next release**" \
43+
--no-issues \
3644
--exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
37-
--max-issues 500 \
38-
--bug-labels IGNOREBUGS
45+
--max-issues 500 \
46+
--bug-labels IGNOREBUGS ${OPTS}

Diff for: .travis/generate_changelog_and_tag_release.sh

+6-9
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ if [ ! -f .gitignore ]; then
3030
exit 1
3131
fi
3232

33-
echo "--- Executing Tagging facility to determine TAG ---"
34-
source .travis/tagger.sh
35-
36-
echo "--- Changelog generator and tagger script starting ---"
37-
# If tagger script hasn't produced a TAG, there is nothing to do so bail out happy
33+
echo "--- Changelog generator script starting ---"
34+
# If we dont have a produced TAG there is nothing to do, so bail out happy
3835
if [ -z "${GIT_TAG}" ]; then
39-
echo "GIT_TAG is empty, nothing to do for now (Value: $GIT_TAG)"
40-
exit 0
36+
echo "GIT_TAG is empty, that is not suppose to happen (Value: $GIT_TAG)"
37+
exit 1
4138
fi
4239

4340
if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
@@ -55,8 +52,8 @@ echo "---- UPDATE VERSION FILE ----"
5552
echo "$GIT_TAG" >packaging/version
5653
git add packaging/version
5754

58-
echo "---- GENERATE CHANGELOG -----"
59-
./.travis/generate_changelog_for_release.sh
55+
echo "---- Create CHANGELOG -----"
56+
./.travis/create_changelog.sh
6057
git add CHANGELOG.md
6158

6259
echo "---- COMMIT AND PUSH CHANGES ----"

Diff for: .travis/generate_changelog_for_nightlies.sh

+4-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
#
3-
# Changelog generation scriptlet.
3+
# Changelog generation scriptlet, for nightlies
44
#
55
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
66
#
@@ -20,39 +20,18 @@ fi
2020
LAST_TAG="$1"
2121
COMMITS_SINCE_RELEASE="$2"
2222
NEW_VERSION="${LAST_TAG}-$((COMMITS_SINCE_RELEASE + 1))-nightly"
23-
ORG=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f1)
24-
PROJECT=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 2)
2523
GIT_MAIL=${GIT_MAIL:-"[email protected]"}
2624
GIT_USER=${GIT_USER:-"netdatabot"}
2725
PUSH_URL=$(git config --get remote.origin.url | sed -e 's/^https:\/\///')
2826
FAIL=0
29-
if [ -z ${GIT_TAG+x} ]; then
30-
OPTS=""
31-
else
32-
OPTS="--future-release ${GIT_TAG}"
33-
fi
34-
echo "We got $COMMITS_SINCE_RELEASE changes since $LAST_TAG, re-generating changelog"
3527

3628
if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
3729
echo "Beta mode on ${TRAVIS_REPO_SLUG}, nothing else to do here"
3830
exit 0
3931
fi
4032

41-
git checkout master
42-
git pull
43-
44-
echo "Running project markmandel for github changelog generation"
45-
#docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
46-
docker run -it -v "$(pwd)":/project markmandel/github-changelog-generator:latest \
47-
--user "${ORG}" \
48-
--project "${PROJECT}" \
49-
--token "${GITHUB_TOKEN}" \
50-
--since-tag "v1.10.0" \
51-
--unreleased-label "**Next release**" \
52-
--no-issues \
53-
--exclude-labels "stale,duplicate,question,invalid,wontfix,discussion,no changelog" \
54-
--max-issues 500 \
55-
--bug-labels IGNOREBUGS
33+
echo "Running changelog creation mechanism"
34+
.travis/create_changelog.sh
5635

5736
echo "Changelog created! Adding packaging/version(${NEW_VERSION}) and CHANGELOG.md to the repository"
5837
echo "${NEW_VERSION}" > packaging/version

Diff for: .travis/nightlies.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
#
33
# This is the nightly changelog generation script
44
# It is responsible for two major activities:
@@ -29,7 +29,7 @@ PREVIOUS_NIGHTLY_COUNT="$(rev <packaging/version | cut -d- -f 2 | rev)"
2929

3030
# If no commits since release, just stop
3131
if [ "${COMMITS_SINCE_RELEASE}" == "${PREVIOUS_NIGHTLY_COUNT}" ]; then
32-
echo "No changes since last nighthly release"
32+
echo "No changes since last nighthly release, nothing else to do"
3333
exit 0
3434
fi
3535

@@ -39,6 +39,7 @@ if [ ! "${TRAVIS_REPO_SLUG}" == "netdata/netdata" ]; then
3939
fi
4040

4141
echo "--- Running Changelog generation ---"
42+
echo "We got $COMMITS_SINCE_RELEASE changes since $LAST_TAG, re-generating changelog"
4243
NIGHTLIES_CHANGELOG_FAILED=0
4344
.travis/generate_changelog_for_nightlies.sh "${LAST_TAG}" "${COMMITS_SINCE_RELEASE}" || NIGHTLIES_CHANGELOG_FAILED=1
4445

Diff for: .travis/tagger.sh

+27-43
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#!/bin/bash
2-
#
3-
# Original script is available at https://github.com/paulfantom/travis-helper/blob/master/releasing/releaser.sh
1+
# #BASH library
42
#
53
# Tags are generated by searching for a keyword in last commit message. Keywords are:
64
# - [patch] or [fix] to bump patch number
@@ -12,33 +10,18 @@
1210
# - GITHUB_TOKEN variable set with GitHub token. Access level: repo.public_repo
1311
# - git-semver python package (pip install git-semver)
1412
#
15-
# Note: Exported variables needed by .travis/draft_release.sh
16-
#
1713
# Original script is available at https://github.com/paulfantom/travis-helper/blob/master/releasing/releaser.sh
1814
#
1915
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
2016
#
2117
# Author : Pawel Krupa (paulfantom)
2218
# Author : Pavlos Emm. Katsoulakis ([email protected])
2319

24-
set -e
25-
26-
27-
# If we are not in netdata git repo, at the top level directory, fail
28-
TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
29-
CWD=$(git rev-parse --show-cdup || echo "")
30-
if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
31-
echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
32-
echo "Changelog generation process aborted"
33-
exit 1
34-
fi
35-
36-
3720
# Figure out what will be new release candidate tag based only on previous ones.
3821
# This assumes that RELEASES are in format of "v0.1.2" and prereleases (RCs) are using "v0.1.2-rc0"
3922
function set_tag_release_candidate() {
4023
LAST_TAG=$(git semver)
41-
echo "Last tag found is: ${LAST_TAG}"
24+
echo "${0}: Last tag found is: ${LAST_TAG}"
4225

4326
if [[ $LAST_TAG =~ -rc* ]]; then
4427
VERSION=$(echo "$LAST_TAG" | cut -d'-' -f 1)
@@ -47,31 +30,32 @@ function set_tag_release_candidate() {
4730
else
4831
VERSION="$(git semver --next-minor)"
4932
RC=0
50-
echo "Warning: Will set version to ${VERSION} (Last tag: ${LAST_TAG}) while tagged for release candidate generation"
33+
echo "${0}: Warning: Will set version to ${VERSION} (Last tag: ${LAST_TAG}) while tagged for release candidate generation"
5134
fi
35+
5236
GIT_TAG="v${VERSION}-rc${RC}"
37+
echo "${0}: Generated a new tag, set to: (${GIT_TAG})"
5338
}
5439

55-
echo "Determining TAG"
56-
57-
# Check if current commit is tagged or not
58-
GIT_TAG=$(git tag --points-at)
59-
60-
if [ -z "${GIT_TAG}" ]; then
61-
git semver
62-
# Figure out next tag based on commit message
63-
echo "Last commit message: ${TRAVIS_COMMIT_MESSAGE}"
64-
case "${TRAVIS_COMMIT_MESSAGE}" in
65-
*"[netdata patch release]"*) GIT_TAG="v$(git semver --next-patch)" ;;
66-
*"[netdata minor release]"*) GIT_TAG="v$(git semver --next-minor)" ;;
67-
*"[netdata major release]"*) GIT_TAG="v$(git semver --next-major)" ;;
68-
*"[netdata release candidate]"*) set_tag_release_candidate ;;
69-
*)
70-
echo "Keyword not detected. Exiting..."
71-
exit 0
72-
;;
73-
esac
74-
fi
75-
76-
echo "Setting up GIT_TAG to ${GIT_TAG}"
77-
export GIT_TAG
40+
function set_tag_for_release() {
41+
echo "${0}: Checking for tag existence"
42+
if [ -z "${GIT_TAG}" ]; then
43+
echo "${0}: No tag was found, generating a new tag"
44+
git semver
45+
46+
echo "${0}: Last commit message: ${TRAVIS_COMMIT_MESSAGE}"
47+
48+
# Figure out next tag based on commit message
49+
case "${TRAVIS_COMMIT_MESSAGE}" in
50+
*"[netdata patch release]"*) GIT_TAG="v$(git semver --next-patch)" ;;
51+
*"[netdata minor release]"*) GIT_TAG="v$(git semver --next-minor)" ;;
52+
*"[netdata major release]"*) GIT_TAG="v$(git semver --next-major)" ;;
53+
*"[netdata release candidate]"*) set_tag_release_candidate ;;
54+
*)
55+
echo "${0}: Keyword not detected. Nothing to set for GIT_TAG"
56+
;;
57+
esac
58+
else
59+
echo "${0}: We seem to already have a GIT_TAG set to (${GIT_TAG})"
60+
fi
61+
}

0 commit comments

Comments
 (0)