From 96b2edec607680ad5f4d3f3de2846f8c7774a202 Mon Sep 17 00:00:00 2001 From: Paul Abel <128620221+pdabelf5@users.noreply.github.com> Date: Tue, 23 Jan 2024 18:09:18 +0000 Subject: [PATCH] Split version update script (#4961) --- .github/scripts/release-notes-update.sh | 55 +++++++++++++++++++++++ .github/scripts/release-version-update.sh | 20 ++------- .github/workflows/release-pr.yml | 12 ++++- hack/changelog-template.txt | 2 +- 4 files changed, 71 insertions(+), 18 deletions(-) create mode 100755 .github/scripts/release-notes-update.sh diff --git a/.github/scripts/release-notes-update.sh b/.github/scripts/release-notes-update.sh new file mode 100755 index 0000000000..47adb43b90 --- /dev/null +++ b/.github/scripts/release-notes-update.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +set -o pipefail + +ROOTDIR=$(git rev-parse --show-toplevel || echo ".") +TMPDIR=/tmp +DEBUG=${DEBUG:-"false"} + +DOCS_TO_UPDATE_FOLDER=${ROOTDIR}/docs/content + + usage() { + echo "Usage: $0 " + exit 1 + } + +ic_version=$1 +helm_chart_version=$2 +k8s_versions=$3 +release_date=$4 + +if [ -z "${ic_version}" ]; then + usage +fi + +if [ -z "${helm_chart_version}" ]; then + usage +fi + +if [ -z "${k8s_versions}" ]; then + usage +fi + +if [ -z "${release_date}" ]; then + usage +fi + +# update releases docs +file_path=${DOCS_TO_UPDATE_FOLDER}/releases.md +if [ "${DEBUG}" != "false" ]; then + echo "Processing ${file_path}" +fi +file_name=$(basename "${file_path}") +mv "${file_path}" "${TMPDIR}/${file_name}" +sed -e "8r ${ROOTDIR}/hack/changelog-template.txt" "${TMPDIR}/${file_name}" | sed \ + -e "s/%%TITLE%%/## $ic_version/g" \ + -e "s/%%IC_VERSION%%/$ic_version/g" \ + -e "s/%%HELM_CHART_VERSION%%/$helm_chart_version/g" \ + -e "s/%%K8S_VERSIONS%%/$k8s_versions.\n/g" \ + -e "s/%%RELEASE_DATE%%/$release_date/g" \ + > ${file_path} +if [ $? -ne 0 ]; then + echo "ERROR: failed processing ${file_path}" + mv "${TMPDIR}/${file_name}" "${file_path}" + exit 2 +fi diff --git a/.github/scripts/release-version-update.sh b/.github/scripts/release-version-update.sh index 177b11f0e4..ee2ab94e3c 100755 --- a/.github/scripts/release-version-update.sh +++ b/.github/scripts/release-version-update.sh @@ -49,14 +49,16 @@ if [ -z "${helm_chart_version}" ]; then fi current_ic_version=$(yq '.appVersion' <"${HELM_CHART_PATH}/Chart.yaml") +escaped_current_ic_version=$(printf '%s' "$current_ic_version" | sed -e 's/\./\\./g'); current_helm_chart_version=$(yq '.version' <"${HELM_CHART_PATH}/Chart.yaml") +escaped_current_helm_chart_version=$(printf '%s' "$current_helm_chart_version" | sed -e 's/\./\\./g'); echo "Updating versions: " echo "ic_version: ${current_ic_version} -> ${ic_version}" echo "helm_chart_version: ${current_helm_chart_version} -> ${helm_chart_version}" -regex_ic="s#$current_ic_version#$ic_version#g" -regex_helm="s#$current_helm_chart_version#$helm_chart_version#g" +regex_ic="s#$escaped_current_ic_version#$ic_version#g" +regex_helm="s#$escaped_current_helm_chart_version#$helm_chart_version#g" mv "${HELM_CHART_PATH}/values.schema.json" "${TMPDIR}/" jq --arg version "${ic_version}" \ @@ -115,17 +117,3 @@ for i in ${docs_files}; do exit 2 fi done - -# update releases docs -file_path=${DOCS_TO_UPDATE_FOLDER}/releases.md -if [ "${DEBUG}" != "false" ]; then - echo "Processing ${file_path}" -fi -file_name=$(basename "${file_path}") -mv "${file_path}" "${TMPDIR}/${file_name}" -cat "${TMPDIR}/${file_name}" | sed -e "8r ${ROOTDIR}/hack/changelog-template.txt" | sed -e "s/%%TITLE%%/## $ic_version/g" -e "s/%%IC_VERSION%%/$ic_version/g" -e "s/%%HELM_CHART_VERSION%%/$helm_chart_version/g" > ${file_path} -if [ $? -ne 0 ]; then - echo "ERROR: failed processing ${file_path}" - mv "${TMPDIR}/${file_name}" "${file_path}" - exit 2 -fi diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 6f52340813..60ba79dd82 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -11,6 +11,14 @@ on: description: "Helm version to release" required: true default: "0.0.0" + k8s_versions: + description: "Kubernetes versions this release has been tested on" + required: true + default: "x.xx-x.xx" + release_date: + description: "Date for this release" + required: true + default: "%d %b %Y" defaults: run: @@ -39,7 +47,9 @@ jobs: token: ${{ secrets.NGINX_PAT }} - name: Replace - run: .github/scripts/release-version-update.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.helm_version }} + run: | + .github/scripts/release-version-update.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.helm_version }} + .github/scripts/release-notes-update.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.helm_version }} "${{ github.event.inputs.k8s_versions }}" "${{ github.event.inputs.release_date }}" - name: Create Pull Request uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 diff --git a/hack/changelog-template.txt b/hack/changelog-template.txt index 604d1ae9b5..3d48f310cf 100644 --- a/hack/changelog-template.txt +++ b/hack/changelog-template.txt @@ -28,4 +28,4 @@ or build your own image using the %%IC_VERSION%% source code We will provide technical support for NGINX Ingress Controller on any Kubernetes platform that is currently supported by its provider and that passes the Kubernetes conformance tests. This release was fully tested on the following Kubernetes -versions: x.xx-x.xx. +versions: %%K8S_VERSIONS%%