summaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
authorPaul Emm. Katsoulakis <34388743+paulkatsoulakis@users.noreply.github.com>2019-05-03 15:24:45 +0300
committerGitHub <noreply@github.com>2019-05-03 15:24:45 +0300
commit7f3c5f6c0123434c5bc500512c4ee139d7342dbd (patch)
treed2ca85cbc1dad486b4f73bcfd177dd7fcd08dbf6 /packaging
parent42f7d7acb7e43b82cbafa18c167b9b7c778d0694 (diff)
netdata/packaging/ci: Create manual nightly deployment tool (#5899)
* netdata/packaging/ci: Create manual nightly deployment tool 1. Alter docker tools to shebang with /usr/bin/env, safer to detect the right BASH (>4.0) 2. Generate script packaging/manual_nightly_deployment.sh, that runs only from TLD of netdata GIT and provides the means to deploy to docker and GCS the latest nightly build of netdata. Only option passed to the script is whether you want to deploy in docker, gcs or both. Note: for GCS deployment the user has to define which bucket to update. Note2: this tool has a hard dependency on gsutil to be properly setup on the development environment * netdata/packaging/ci: Do not change global config for mail and user Since we are now starting to use these scripts externally, we need to make sure we dont mess developer config. It seems that we are touching global config, in an attempt to modify a single commit message. Alter this and instead use the --author option for the single commit that we care about instead of altering the universe Cheers
Diffstat (limited to 'packaging')
-rwxr-xr-xpackaging/docker/build.sh2
-rwxr-xr-xpackaging/docker/publish.sh1
-rwxr-xr-xpackaging/manual_nightly_deployment.sh127
3 files changed, 129 insertions, 1 deletions
diff --git a/packaging/docker/build.sh b/packaging/docker/build.sh
index 148db5cd2e..f15c7dad72 100755
--- a/packaging/docker/build.sh
+++ b/packaging/docker/build.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-# Cross-arch docker build helper script
+#
#
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
#
diff --git a/packaging/docker/publish.sh b/packaging/docker/publish.sh
index 0e65553e18..948787b0bf 100755
--- a/packaging/docker/publish.sh
+++ b/packaging/docker/publish.sh
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
+#
# Cross-arch docker publish helper script
# Needs docker in version >18.02 due to usage of manifests
#
diff --git a/packaging/manual_nightly_deployment.sh b/packaging/manual_nightly_deployment.sh
new file mode 100755
index 0000000000..a0999bb188
--- /dev/null
+++ b/packaging/manual_nightly_deployment.sh
@@ -0,0 +1,127 @@
+#!/usr/bin/env bash
+#
+# This tool allows netdata team to manually deploy nightlies
+# It emulates the nightly operations required for a new version to be published for our users
+#
+# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Author : Pavlos Emm. Katsoulakis <paul@netdata.cloud>
+#
+set -e
+
+# 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
+
+if [ $# -lt 1 ] || [ $# -gt 2 ]; then
+ echo "Run as ./$(basename "$0") [docker|gcs]|all] from the top level directory of netdata GIT repository"
+ exit 1
+fi
+
+GSUTIL_BINARY=$(command -v gsutil 2> /dev/null)
+if [ -z "${GSUTIL_BINARY}" ]; then
+ echo "No gsutil utility available, you need gsutil deployed to manually deploy to GCS"
+ exit 1
+fi;
+
+# Function declarations
+publish_docker() {
+
+ # Ensure REPOSITORY present
+ if [ -z "${REPOSITORY}" ]; then
+ echo "Please provide the repository to deploy the containers:"
+ read -r REPOSITORY
+ export REPOSITORY
+ else
+ echo "Docker publishing to ${REPOSITORY}"
+ fi
+
+ # Ensure DOCKER_USERNAME present
+ if [ -z "${DOCKER_USERNAME}" ]; then
+ echo "For repository ${REPOSITORY}, Please provide the docker USERNAME to use:"
+ read -r DOCKER_USERNAME
+ export DOCKER_USERNAME
+ else
+ echo "Using docker username ${DOCKER_USERNAME}"
+ fi
+
+ # Ensure DOCKER_PASS present
+ if [ -z "${DOCKER_PASS}" ]; then
+ echo "Username ${DOCKER_USERNAME} received, now give me the password:"
+ read -r -s DOCKER_PASS
+ export DOCKER_PASS
+ else
+ echo "Docker password has already been set to env, using that"
+ fi
+
+ echo "Building Docker images.."
+ packaging/docker/build.sh
+
+ echo "Publishing Docker images.."
+ packaging/docker/publish.sh
+}
+
+publish_nightly_binaries() {
+ echo "Publishing nightly binaries to GCS"
+
+ echo "Please select the bucket to sync, from the ones available to you:"
+ bucket_list=$(${GSUTIL_BINARY} list | tr '\n' ' ')
+ declare -A buckets
+ idx=0
+ for abucket in ${bucket_list}; do
+ echo "${idx}. ${abucket}"
+ buckets["${idx}"]=${abucket}
+ ((idx=idx+1))
+ done
+ read -p"Selection>" -r -n 1 selected_bucket
+
+ echo "Ok!"
+ echo "Syncing artifacts directory contents with GCS bucket: ${buckets[${selected_bucket}]}"
+ if [ -d artifacts ]; then
+ ${GSUTIL_BINARY} -m rsync -r artifacts "${buckets["${selected_bucket}"]}"
+ echo "GCS Sync complete!"
+ else
+ echo "Directory artifacts does not exist, nothing to do on GCS"
+ fi
+}
+
+prepare_and_publish_gcs() {
+ # Prepare the artifacts directory
+ echo "Preparing artifacts directory contents"
+ .travis/create_artifacts.sh
+
+ # Publish it to GCS
+ publish_nightly_binaries
+
+ # Clean up
+ echo "Cleaning up repository"
+ make clean || echo "Nothing to clean"
+ make distclean || echo "Nothing to distclean"
+ rm -rf artifacts
+}
+
+# Mandatory variable declarations
+export TRAVIS_REPO_SLUG="netdata/netdata"
+
+echo "Manual nightly deployment procedure started"
+case "$1" in
+ "docker")
+ publish_docker
+ ;;
+ "gcs")
+ prepare_and_publish_gcs
+ ;;
+ "all")
+ publish_docker
+ prepare_and_publish_gcs
+ ;;
+ *)
+ echo "ERROR: Invalid request parameter $1. Valid values are: docker, gcs, all"
+ ;;
+esac
+echo "Manual nightly deployment completed!"