From b056696c4605731412e0bfdea72f0df124bd909b Mon Sep 17 00:00:00 2001 From: Paul Abel <128620221+pdabelf5@users.noreply.github.com> Date: Mon, 20 Nov 2023 18:25:30 +0000 Subject: [PATCH] fix: update release action to use script (#4677) This change updates the release actions to use a script that is easier to test by a developer. It also updates the location of the helm files in the release scripts and documentation. --- .github/scripts/release-version-update.sh | 131 ++++++++++++++++++ .github/workflows/release-pr.yml | 37 +---- README.md | 2 +- charts/nginx-ingress/README.md | 8 +- charts/nginx-ingress/values.schema.json | 10 +- docs/content/configuration/security.md | 2 +- .../installing-nic/installation-with-helm.md | 12 +- .../using-the-jwt-token-docker-secret.md | 4 +- .../troubleshooting/troubleshoot-common.md | 2 +- docs/content/tutorials/custom-listen-ports.md | 2 +- .../service-insight/README.md | 4 +- 11 files changed, 155 insertions(+), 59 deletions(-) create mode 100755 .github/scripts/release-version-update.sh diff --git a/.github/scripts/release-version-update.sh b/.github/scripts/release-version-update.sh new file mode 100755 index 0000000000..efddb21d85 --- /dev/null +++ b/.github/scripts/release-version-update.sh @@ -0,0 +1,131 @@ +#!/usr/bin/env bash + +set -o pipefail + +ROOTDIR=$(git rev-parse --show-toplevel || echo ".") +TMPDIR=/tmp +HELM_CHART_PATH="${ROOTDIR}/charts/nginx-ingress" +DEPLOYMENT_PATH="${ROOTDIR}/deployments" +DEBUG=${DEBUG:-"false"} + +DOCS_TO_UPDATE_FOLDER=${ROOTDIR}/docs/content +FILES_TO_UPDATE_IC_VERSION=( + "${ROOTDIR}/README.md" + "${DEPLOYMENT_PATH}/daemon-set/nginx-ingress.yaml" + "${DEPLOYMENT_PATH}/daemon-set/nginx-plus-ingress.yaml" + "${DEPLOYMENT_PATH}/deployment/nginx-ingress.yaml" + "${DEPLOYMENT_PATH}/deployment/nginx-plus-ingress.yaml" + "${HELM_CHART_PATH}/Chart.yaml" + "${HELM_CHART_PATH}/README.md" + "${HELM_CHART_PATH}/values-icp.yaml" + "${HELM_CHART_PATH}/values-nsm.yaml" + "${HELM_CHART_PATH}/values-plus.yaml" + "${HELM_CHART_PATH}/values.yaml" +) +FILE_TO_UPDATE_HELM_CHART_VERSION=( + "${HELM_CHART_PATH}/Chart.yaml" + "${HELM_CHART_PATH}/README.md" +) + + usage() { + echo "Usage: $0 " + exit 1 + } + +if ! command -v yq > /dev/null 2>&1; then + echo "ERROR: yq command not found in \$PATH, cannot continue, exiting..." + exit 2 +fi + +ic_version=$1 +helm_chart_version=$2 + +if [ -z "${ic_version}" ]; then + usage +fi + +if [ -z "${helm_chart_version}" ]; then + usage +fi + +current_ic_version=$(yq '.appVersion' <"${HELM_CHART_PATH}/Chart.yaml") +current_helm_chart_version=$(yq '.version' <"${HELM_CHART_PATH}/Chart.yaml") + +echo "Updating versions: " +echo "ic_version: ${current_ic_version} -> ${ic_version}" +echo "helm_chart_version: ${current_helm_chart_version} -> ${helm_chart_version}" + +mv "${HELM_CHART_PATH}/values.schema.json" "${TMPDIR}/" +jq --arg version "${ic_version}" \ + '.properties.controller.properties.image.properties.tag.default = $version | .properties.controller.properties.image.properties.tag.examples[0] = $version | .properties.controller.examples[0].image.tag = $version | .properties.controller.properties.image.examples[0].tag = $version | .examples[0].controller.image.tag = $version' \ + ${TMPDIR}/values.schema.json \ + > "${HELM_CHART_PATH}/values.schema.json" +rc=$? +if [ $rc -ne 0 ]; then + echo "ERROR: failed updating ic_version in values.schema.json" + mv "${TMPDIR}/values.schema.json" "${HELM_CHART_PATH}/values.schema.json" + exit 2 +fi + +# update helm chart & deployment files with IC version +for i in "${FILES_TO_UPDATE_IC_VERSION[@]}"; do + if [ "${DEBUG}" != "false" ]; then + echo "Processing ${i}" + fi + file_name=$(basename "${i}") + mv "${i}" "${TMPDIR}/${file_name}" + regex="s#$current_ic_version#$ic_version#g" + cat "${TMPDIR}/${file_name}" | sed -e "$regex" > "${i}" + if [ $? -ne 0 ]; then + echo "ERROR: failed processing ${i}" + mv "${TMPDIR}/${file_name}" "${i}" + exit 2 + fi +done + +# update helm chart files with helm chart version +for i in "${FILE_TO_UPDATE_HELM_CHART_VERSION[@]}"; do + if [ "${DEBUG}" != "false" ]; then + echo "Processing ${i}" + fi + file_name=$(basename "${i}") + mv "${i}" "${TMPDIR}/${file_name}" + regex="s#$current_ic_version#$ic_version#g" + cat "${TMPDIR}/${file_name}" | sed -e "$regex" > "${i}" + if [ $? -ne 0 ]; then + echo "ERROR: failed processing ${i}" + mv "${TMPDIR}/${file_name}" "${i}" + exit 2 + fi +done + +# update docs with new versions +docs_files=$(find "${DOCS_TO_UPDATE_FOLDER}" -type f -name "*.md" ! -name releases.md ! -name CHANGELOG.md) +for i in ${docs_files}; do + if [ "${DEBUG}" != "false" ]; then + echo "Processing ${i}" + fi + file_name=$(basename "${i}") + mv "${i}" "${TMPDIR}/${file_name}" + regex="s#$current_ic_version#$ic_version#g" + cat "${TMPDIR}/${file_name}" | sed -e "$regex" > "${i}" + if [ $? -ne 0 ]; then + echo "ERROR: failed processing ${i}" + mv "${TMPDIR}/${file_name}" "${i}" + 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 d34e913b04..39aac512a8 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -34,42 +34,7 @@ jobs: token: ${{ secrets.NGINX_PAT }} - name: Replace - run: | - - DOCS_TO_UPDATE_FOLDER=docs/content - - FILES_TO_UPDATE_IC_VERSION=( - README.md - deployments/daemon-set/nginx-ingress.yaml - deployments/daemon-set/nginx-plus-ingress.yaml - deployments/deployment/nginx-ingress.yaml - deployments/deployment/nginx-plus-ingress.yaml - deployments/helm-chart/Chart.yaml - deployments/helm-chart/README.md - deployments/helm-chart/values-icp.yaml - deployments/helm-chart/values-nsm.yaml - deployments/helm-chart/values-plus.yaml - deployments/helm-chart/values.yaml - ) - - FILE_TO_UPDATE_HELM_CHART_VERSION=( - deployments/helm-chart/Chart.yaml - deployments/helm-chart/README.md - ) - - ic_version=${{ github.event.inputs.version }} - helm_chart_version=${{ github.event.inputs.helm_version }} - - current_ic_version=$(yq '.appVersion' -nginx-ingress ``` -2. Checkout the latest available tag using `git checkout v3.3.0` +2. Checkout the latest available tag using `git checkout v3.3.2` -3. Navigate to `/kubernates-ingress/deployments/helm-chart` +3. Navigate to `/kubernates-ingress/charts/nginx-ingress` -4. Update the `selectorLabels: {}` field in the `values.yaml` file located at `/kubernates-ingress/deployments/helm-chart` with the copied `Selector` value. +4. Update the `selectorLabels: {}` field in the `values.yaml` file located at `/kubernates-ingress/charts/nginx-ingress` with the copied `Selector` value. ```shell selectorLabels: {app: -nginx-ingress} diff --git a/docs/content/installation/nic-images/using-the-jwt-token-docker-secret.md b/docs/content/installation/nic-images/using-the-jwt-token-docker-secret.md index 8ec66bb672..fe1b57bfd7 100644 --- a/docs/content/installation/nic-images/using-the-jwt-token-docker-secret.md +++ b/docs/content/installation/nic-images/using-the-jwt-token-docker-secret.md @@ -78,7 +78,7 @@ spec: seccompProfile: type: RuntimeDefault containers: - - image: private-registry.nginx.com/nginx-ic/nginx-plus-ingress:3.2.0 + - image: private-registry.nginx.com/nginx-ic/nginx-plus-ingress:3.3.2 imagePullPolicy: IfNotPresent name: nginx-plus-ingress ``` @@ -96,7 +96,7 @@ If you are using Helm for deployment, there are two main methods: using *sources The [Installation with Helm ]({{< relref "installation/installing-nic/installation-with-helm.md#managing-the-chart-via-sources" >}}) documentation has a section describing how to use sources: these are the unique steps for Docker secrets using JWT tokens. 1. Clone the NGINX [`kubernetes-ingress` repository](https://github.com/nginxinc/kubernetes-ingress). -1. Navigate to the `deployments/helm-chart` folder of your local clone. +1. Navigate to the `charts/nginx-ingress` folder of your local clone. 1. Open the `values.yaml` file in an editor. You must change a few lines NGINX Ingress Controller with NGINX Plus to be deployed. diff --git a/docs/content/troubleshooting/troubleshoot-common.md b/docs/content/troubleshooting/troubleshoot-common.md index 63ff8f31e8..c29e0f02eb 100644 --- a/docs/content/troubleshooting/troubleshoot-common.md +++ b/docs/content/troubleshooting/troubleshoot-common.md @@ -145,7 +145,7 @@ controller: nginxplus: plus image: repository: nginx/nginx-ingress - tag: 3.3.0 + tag: 3.3.2 # NGINX Configmap config: entries: diff --git a/docs/content/tutorials/custom-listen-ports.md b/docs/content/tutorials/custom-listen-ports.md index b7fcac13ca..2a38a1efaf 100644 --- a/docs/content/tutorials/custom-listen-ports.md +++ b/docs/content/tutorials/custom-listen-ports.md @@ -88,7 +88,7 @@ spec: spec: serviceAccountName: nginx-ingress containers: - - image: nginx/nginx-ingress:3.3.0 + - image: nginx/nginx-ingress:3.3.2 imagePullPolicy: IfNotPresent name: nginx-ingress ports: diff --git a/examples/custom-resources/service-insight/README.md b/examples/custom-resources/service-insight/README.md index 09c4e8b40a..5580368ccd 100644 --- a/examples/custom-resources/service-insight/README.md +++ b/examples/custom-resources/service-insight/README.md @@ -32,7 +32,7 @@ spec: securityContext: ... containers: - - image: nginx-plus-ingress:3.3.0 + - image: nginx-plus-ingress:3.3.2 imagePullPolicy: IfNotPresent name: nginx-plus-ingress ports: @@ -321,7 +321,7 @@ spec: securityContext: ... containers: - - image: nginx-plus-ingress:3.3.0 + - image: nginx-plus-ingress:3.3.2 imagePullPolicy: IfNotPresent name: nginx-plus-ingress ports: