Skip to content

Commit

Permalink
allow to choose previous nic/chart version (#5276) (#5277)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdabelf5 committed Mar 20, 2024
1 parent 2c2fba3 commit 6eca1f8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
33 changes: 18 additions & 15 deletions .github/scripts/release-version-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,43 @@ FILE_TO_UPDATE_HELM_CHART_VERSION=(
)

usage() {
echo "Usage: $0 <ic_version> <helm_chart_version>"
echo "Usage: $0 <current_ic_version> <current_helm_chart_version> <new_ic_version> <new_helm_chart_version>"
exit 1
}

if ! command -v yq > /dev/null 2>&1; then
echo "ERROR: yq command not found in \$PATH, cannot continue, exiting..."
exit 2
current_ic_version=$1
current_helm_chart_version=$2
new_ic_version=$3
new_helm_chart_version=$4

if [ -z "${current_ic_version}" ]; then
usage
fi

ic_version=$1
helm_chart_version=$2
if [ -z "${current_helm_chart_version}" ]; then
usage
fi

if [ -z "${ic_version}" ]; then
if [ -z "${new_ic_version}" ]; then
usage
fi

if [ -z "${helm_chart_version}" ]; then
if [ -z "${new_helm_chart_version}" ]; then
usage
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}"
echo "ic_version: ${current_ic_version} -> ${new_ic_version}"
echo "helm_chart_version: ${current_helm_chart_version} -> ${new_helm_chart_version}"

regex_ic="s#$escaped_current_ic_version#$ic_version#g"
regex_helm="s#$escaped_current_helm_chart_version#$helm_chart_version#g"
regex_ic="s#$escaped_current_ic_version#$new_ic_version#g"
regex_helm="s#$escaped_current_helm_chart_version#$new_helm_chart_version#g"

mv "${HELM_CHART_PATH}/values.schema.json" "${TMPDIR}/"
jq --arg version "${ic_version}" \
jq --arg version "${new_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"
Expand Down
28 changes: 18 additions & 10 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ name: Release PR
on:
workflow_dispatch:
inputs:
version:
current_version:
description: "Current version to replace"
required: true
default: "3.3.2"
new_version:
description: "Version to release"
required: true
default: "0.0.0"
helm_version:
default: "3.4.3"
current_helm_version:
description: "Current helm version to replace"
required: true
default: "1.0.2"
new_helm_version:
description: "Helm version to release"
required: true
default: "0.0.0"
default: "1.1.3"
k8s_versions:
description: "Kubernetes versions this release has been tested on"
required: true
Expand Down Expand Up @@ -48,16 +56,16 @@ jobs:

- name: Replace
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 }}"
.github/scripts/release-version-update.sh ${{ github.event.inputs.current_version }} ${{ github.event.inputs.current_helm_version }} ${{ github.event.inputs.new_version }} ${{ github.event.inputs.new_helm_version }}
.github/scripts/release-notes-update.sh ${{ github.event.inputs.new_version }} ${{ github.event.inputs.new_helm_version }} "${{ github.event.inputs.k8s_versions }}" "${{ github.event.inputs.release_date }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e # v6.0.2
with:
token: ${{ secrets.NGINX_PAT }}
commit-message: Release ${{ github.event.inputs.version }}
title: Release ${{ github.event.inputs.version }}
branch: docs/release-${{ github.event.inputs.version }}
commit-message: Release ${{ github.event.inputs.new_version }}
title: Release ${{ github.event.inputs.new_version }}
branch: docs/release-${{ github.event.inputs.new_version }}
author: nginx-bot <integrations@nginx.com>
body: |
This automated PR updates the docs for ${{ github.event.inputs.version }} release.
This automated PR updates the docs for ${{ github.event.inputs.new_version }} release.

0 comments on commit 6eca1f8

Please sign in to comment.