Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add makefile target to prepare release #1349

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ ci.aws-acceptance-test-cleanup: ## Deletes AWS resources left behind after faile
version:
@echo $(VERSION)

# ===========> Release Targets

prepare-release: ## Sets the versions, updates changelog to prepare this repository to release
ifndef RELEASE_VERSION
$(error RELEASE_VERSION is required)
endif
source $(CURDIR)/control-plane/build-support/scripts/functions.sh; set_release_mode $(CURDIR) $(RELEASE_VERSION) "$(shell date +"%B %d, %Y")" $(PRERELEASE_VERSION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not blocking)

I was just thinking that it might be useful to be able to set the date so that we could pre-load the PR ahead of time? I guess, whomever is releasing could set the date in the PR if they are doing it early....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah. I'd hold off on this until we need it. Typically we end up doing it the same day IIRC. Definitely easy to improve in the future!



# ===========> Makefile config

.DEFAULT_GOAL := help
Expand Down
66 changes: 64 additions & 2 deletions control-plane/build-support/functions/10-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,52 @@ function update_version {
return $?
}

function update_version_helm {
# Arguments:
# $1 - Path to the directory where the root of the Helm chart is
# $2 - Version string
# $3 - PreRelease version (if unset will become an empty string)
#
# Returns:
# 0 - success
# * - error

if ! test -d "$1"
then
err "ERROR: '$1' is not a directory. update_version_helm must be called with the path to the Helm chart"
return 1
fi

if test -z "$2"
then
err "ERROR: The version specified was empty"
return 1
fi

local vfile="$1/values.yaml"
local cfile="$1/Chart.yaml"
local version="$2"
local prerelease="$3"
local full_version="$2"
if ! test -z "$3"
then
full_version="$2-$3"
fi
local image_k8s="hashicorp\/consul-k8s-control-plane:$full_version"

sed_i ${SED_EXT} -e "s/(imageK8S:[[:space:]]*)\"[^\"]*\"/\1${image_k8s}/g" "${vfile}"
sed_i ${SED_EXT} -e "s/(version:[[:space:]]*)[^\"]*/\1${full_version}/g" "${cfile}"
sed_i ${SED_EXT} -e "s/(image:[[:space:]]*hashicorp\/consul-k8s-control-plane:)[^\"]*/\1${full_version}/g" "${cfile}"

if test -z "$3"
then
sed_i ${SED_EXT} -e "s/(artifacthub.io\/prerelease:[[:space:]]*)[^\"]*/\1false/g" "${cfile}"
else
sed_i ${SED_EXT} -e "s/(artifacthub.io\/prerelease:[[:space:]]*)[^\"]*/\1true/g" "${cfile}"
fi
return $?
}

function set_changelog_version {
# Arguments:
# $1 - Path to top level Consul source
Expand Down Expand Up @@ -744,6 +790,8 @@ function set_release_mode {
return 1
fi

echo "release version: " $1 $2 $3 $4

if test -z "$2"
then
err "ERROR: The version specified was empty"
Expand All @@ -768,8 +816,22 @@ function set_release_mode {
status_stage "==> Updating CHANGELOG.md with release info: ${changelog_vers} (${rel_date})"
set_changelog_version "${sdir}" "${changelog_vers}" "${rel_date}" || return 1

status_stage "==> Updating version/version.go"
if ! update_version "${sdir}/version/version.go" "${vers}" "$4"
status_stage "==> Updating control-plane version/version.go"
if ! update_version "${sdir}/control-plane/version/version.go" "${vers}" "$4"
then
unset_changelog_version "${sdir}"
return 1
fi

status_stage "==> Updating cli version/version.go"
if ! update_version "${sdir}/cli/version/version.go" "${vers}" "$4"
then
unset_changelog_version "${sdir}"
return 1
fi

status_stage "==> Updating Helm chart versions"
if ! update_version_helm "${sdir}/charts/consul" "${vers}" "$4"
then
unset_changelog_version "${sdir}"
return 1
Expand Down