From d99ca00d74775aae23e20f0567efbbf171e74ec4 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Thu, 14 Jun 2018 11:04:04 -0400 Subject: [PATCH] Move some things around and add in consul version confirmation to publishing checks --- build-support/docker/Makefile | 13 ++- build-support/functions/01-util.sh | 51 ----------- build-support/functions/04-publish.sh | 116 +++++++++++++++++++++++++- 3 files changed, 124 insertions(+), 56 deletions(-) diff --git a/build-support/docker/Makefile b/build-support/docker/Makefile index d9af9ed5a..01c468959 100644 --- a/build-support/docker/Makefile +++ b/build-support/docker/Makefile @@ -7,15 +7,22 @@ GO_BUILD_TAG?=consul-build-go UI_BUILD_TAG?=consul-build-ui UI_LEGACY_BUILD_TAG?=consul-build-ui-legacy +DOCKER_BUILD_QUIET?=1 +ifeq (${DOCKER_BUILD_QUIET},1) +QUIET=-q +else +QUIET= +endif + images: go-build-image ui-build-image ui-legacy-build-image go-build-image: - docker build $(NOCACHE) -t $(GO_BUILD_TAG) -f Build-Go.dockerfile . + docker build $(NOCACHE) $(QUIET) -t $(GO_BUILD_TAG) -f Build-Go.dockerfile . ui-build-image: - docker build $(NOCACHE) -t $(UI_BUILD_TAG) -f Build-UI.dockerfile . + docker build $(NOCACHE) $(QUIET) -t $(UI_BUILD_TAG) -f Build-UI.dockerfile . ui-legacy-build-image: - docker build $(NOCACHE) -t $(UI_LEGACY_BUILD_TAG) -f Build-UI-Legacy.dockerfile . + docker build $(NOCACHE) $(QUIET) -t $(UI_LEGACY_BUILD_TAG) -f Build-UI-Legacy.dockerfile . .PHONY: images go-build-image ui-build-image ui-legacy-build-image diff --git a/build-support/functions/01-util.sh b/build-support/functions/01-util.sh index bd8220f7f..9e15005d8 100644 --- a/build-support/functions/01-util.sh +++ b/build-support/functions/01-util.sh @@ -357,57 +357,6 @@ function find_git_remote { return $ret } -function confirm_git_push_changes { - # Arguments: - # $1 - Path to git repo - # - # Returns: - # 0 - success - # * - error - # - - if ! test -d "$1" - then - err "ERROR: '$1' is not a directory. confirm_git_push_changes must be called with the path to a git repo as the first argument'" - return 1 - fi - - pushd "${1}" > /dev/null - - - declare -i ret=0 - git_log_summary || ret=1 - if test ${ret} -eq 0 - then - # put a empty line between the git changes and the prompt - echo "" - - local answer="" - - while true - do - case "${answer}" in - [yY]* ) - status "Changes Accepted" - ret=0 - break - ;; - [nN]* ) - err "Changes Rejected" - ret=1 - break - ;; - * ) - read -p "Are these changes correct? [y/n]: " answer - ;; - esac - done - fi - - popd > /dev/null - return $ret -} - function is_git_clean { # Arguments: # $1 - Path to git repo diff --git a/build-support/functions/04-publish.sh b/build-support/functions/04-publish.sh index ba4e571a1..02abdcdc6 100644 --- a/build-support/functions/04-publish.sh +++ b/build-support/functions/04-publish.sh @@ -72,6 +72,115 @@ function push_git_release { return $ret } +function confirm_git_push_changes { + # Arguments: + # $1 - Path to git repo + # + # Returns: + # 0 - success + # * - error + # + + if ! test -d "$1" + then + err "ERROR: '$1' is not a directory. confirm_git_push_changes must be called with the path to a git repo as the first argument'" + return 1 + fi + + pushd "${1}" > /dev/null + + + declare -i ret=0 + git_log_summary || ret=1 + if test ${ret} -eq 0 + then + # put a empty line between the git changes and the prompt + echo "" + + local answer="" + + while true + do + case "${answer}" in + [yY]* ) + status "Changes Accepted" + ret=0 + break + ;; + [nN]* ) + err "Changes Rejected" + ret=1 + break + ;; + * ) + read -p "Are these changes correct? [y/n]: " answer + ;; + esac + done + fi + + popd > /dev/null + return $ret +} + +function confirm_consul_version { + # Arguments: + # $1 - Path to the release files + # $2 - Version to look for + # + # Returns: + # 0 - success + # * - error + + local zfile="${1}/consul_${2}_$(go env GOOS)_$(go env GOARCH).zip" + + if ! test -f "${zfile}" + then + err "ERROR: File not found or is not a regular file: ${zfile}" + return 1 + fi + + local ret=0 + local tfile="$(mktemp) -t "consul_")" + + unzip -p "${zfile}" "consul" > "${tfile}" + if test $? -eq 0 + then + chmod +x "${tfile}" + "${tfile}" version + + # put a empty line between the version output and the prompt + echo "" + + local answer="" + + while true + do + case "${answer}" in + [yY]* ) + status "Version Accepted" + ret=0 + break + ;; + [nN]* ) + err "Version Rejected" + ret=1 + break + ;; + * ) + read -p "Is this Consul version correct? [y/n]: " answer + ;; + esac + done + else + err "ERROR: Failed to extract consul binary from the zip file" + ret=1 + fi + + rm "${tfile}" > /dev/null 2>&1 + return ${ret} +} + function publish_release { # Arguments: @@ -110,8 +219,11 @@ function publish_release { return 1 fi - status_page "==> Verifying release files" - check_release "${sdir}/pkg/dist" "${vers}" true + status_stage "==> Verifying release files" + check_release "${sdir}/pkg/dist" "${vers}" true || return 1 + + status_stage "==> Confirming Consul Version" + confirm_consul_version "${sdir}/pkg/dist" "${vers}" || return 1 status_stage "==> Confirming Git is clean" is_git_clean "$1" true || return 1