From 829c32d7105a3878bed048de865e913b0ea7995b Mon Sep 17 00:00:00 2001 From: Paul Abel Date: Tue, 23 Jan 2024 12:01:23 +0000 Subject: [PATCH 1/3] escape regex in release version script --- .github/scripts/release-version-update.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/scripts/release-version-update.sh b/.github/scripts/release-version-update.sh index 177b11f0e4..e95a3087f3 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}" \ From 693415d21639d6da9ac58a2bb123ff8a5ee561a6 Mon Sep 17 00:00:00 2001 From: Paul Abel Date: Tue, 23 Jan 2024 12:36:56 +0000 Subject: [PATCH 2/3] split release notes into new script --- .github/scripts/release-notes-update.sh | 55 +++++++++++++++++++++++ .github/scripts/release-version-update.sh | 14 ------ .github/workflows/release-pr.yml | 12 ++++- hack/changelog-template.txt | 2 +- 4 files changed, 67 insertions(+), 16 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 e95a3087f3..ee2ab94e3c 100755 --- a/.github/scripts/release-version-update.sh +++ b/.github/scripts/release-version-update.sh @@ -117,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..dd522a3dc5 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: "Support Kubernetes versions for this release" + 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%% From c9fea48333177e74d6f5f921d515c011efcbcd9d Mon Sep 17 00:00:00 2001 From: Paul Abel Date: Tue, 23 Jan 2024 16:17:18 +0000 Subject: [PATCH 3/3] address feedback on variable description --- .github/workflows/release-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index dd522a3dc5..60ba79dd82 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -12,7 +12,7 @@ on: required: true default: "0.0.0" k8s_versions: - description: "Support Kubernetes versions for this release" + description: "Kubernetes versions this release has been tested on" required: true default: "x.xx-x.xx" release_date: