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

Split version update script #4961

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
55 changes: 55 additions & 0 deletions .github/scripts/release-notes-update.sh
Original file line number Diff line number Diff line change
@@ -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 <ic_version> <helm_chart_version> <k8s_versions> <release_date>"
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
20 changes: 4 additions & 16 deletions .github/scripts/release-version-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down Expand Up @@ -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
12 changes: 11 additions & 1 deletion .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
pdabelf5 marked this conversation as resolved.
Show resolved Hide resolved
required: true
default: "x.xx-x.xx"
release_date:
description: "Date for this release"
required: true
default: "%d %b %Y"

defaults:
run:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hack/changelog-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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%%
Loading