Skip to content

Commit

Permalink
fix: update release action to use script (#4677)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pdabelf5 authored Nov 20, 2023
1 parent 8cdaf64 commit b056696
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 59 deletions.
131 changes: 131 additions & 0 deletions .github/scripts/release-version-update.sh
Original file line number Diff line number Diff line change
@@ -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 <ic_version> <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
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
37 changes: 1 addition & 36 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' <deployments/helm-chart/Chart.yaml)
current_helm_chart_version=$(yq '.version' <deployments/helm-chart/Chart.yaml)
sed -i "s/$current_ic_version/$ic_version/g" ${FILES_TO_UPDATE_IC_VERSION[*]}
sed -i "s/$current_helm_chart_version/$helm_chart_version/g" ${FILE_TO_UPDATE_HELM_CHART_VERSION[*]}
find $DOCS_TO_UPDATE_FOLDER -type f -name "*.md" ! -name releases.md ! -name CHANGELOG.md -exec sed -i "s/$current_ic_version/$ic_version/g" {} +
# update CHANGELOGs
sed -i "8r hack/changelog-template.txt" $DOCS_TO_UPDATE_FOLDER/releases.md
sed -i -e "s/%%TITLE%%/## $ic_version/g" -e "s/%%IC_VERSION%%/$ic_version/g" -e "s/%%HELM_CHART_VERSION%%/$helm_chart_version/g" $DOCS_TO_UPDATE_FOLDER/releases.md CHANGELOG.md
run: .github/scripts/release-version-update.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.helm_version }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ your links to the correct versions:

| Version | Description | Image for NGINX | Image for NGINX Plus | Installation Manifests and Helm Chart | Documentation and Examples |
| ------- | ----------- | --------------- | -------------------- | ---------------------------------------| -------------------------- |
| Latest stable release | For production use | Use the 3.3.2 images from [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/), [GitHub Container](https://github.com/nginxinc/kubernetes-ingress/pkgs/container/kubernetes-ingress), [Amazon ECR Public Gallery](https://gallery.ecr.aws/nginx/nginx-ingress) or [Quay.io](https://quay.io/repository/nginx/nginx-ingress) or [build your own image](https://docs.nginx.com/nginx-ingress-controller/installation/building-ingress-controller-image/). | Use the 3.3.2 images from the [F5 Container Registry](https://docs.nginx.com/nginx-ingress-controller/installation/pulling-ingress-controller-image/) or the [AWS Marketplace](https://aws.amazon.com/marketplace/search/?CREATOR=741df81b-dfdc-4d36-b8da-945ea66b522c&FULFILLMENT_OPTION_TYPE=CONTAINER&filters=CREATOR%2CFULFILLMENT_OPTION_TYPE) or [Build your own image](https://docs.nginx.com/nginx-ingress-controller/installation/building-ingress-controller-image/). | [Manifests](https://github.com/nginxinc/kubernetes-ingress/tree/v3.3.2/deployments). [Helm chart](https://github.com/nginxinc/kubernetes-ingress/tree/v3.3.2/deployments/helm-chart). | [Documentation](https://docs.nginx.com/nginx-ingress-controller/). [Examples](https://docs.nginx.com/nginx-ingress-controller/configuration/configuration-examples/). |
| Latest stable release | For production use | Use the 3.3.2 images from [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/), [GitHub Container](https://github.com/nginxinc/kubernetes-ingress/pkgs/container/kubernetes-ingress), [Amazon ECR Public Gallery](https://gallery.ecr.aws/nginx/nginx-ingress) or [Quay.io](https://quay.io/repository/nginx/nginx-ingress) or [build your own image](https://docs.nginx.com/nginx-ingress-controller/installation/building-ingress-controller-image/). | Use the 3.3.2 images from the [F5 Container Registry](https://docs.nginx.com/nginx-ingress-controller/installation/pulling-ingress-controller-image/) or the [AWS Marketplace](https://aws.amazon.com/marketplace/search/?CREATOR=741df81b-dfdc-4d36-b8da-945ea66b522c&FULFILLMENT_OPTION_TYPE=CONTAINER&filters=CREATOR%2CFULFILLMENT_OPTION_TYPE) or [Build your own image](https://docs.nginx.com/nginx-ingress-controller/installation/building-ingress-controller-image/). | [Manifests](https://github.com/nginxinc/kubernetes-ingress/tree/v3.3.2/deployments). [Helm chart](https://github.com/nginxinc/kubernetes-ingress/tree/v3.3.2/charts/nginx-ingress). | [Documentation](https://docs.nginx.com/nginx-ingress-controller/). [Examples](https://docs.nginx.com/nginx-ingress-controller/configuration/configuration-examples/). |
| Edge/Nightly | For testing and experimenting | Use the edge or nightly images from [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/), [GitHub Container](https://github.com/nginxinc/kubernetes-ingress/pkgs/container/kubernetes-ingress), [Amazon ECR Public Gallery](https://gallery.ecr.aws/nginx/nginx-ingress) or [Quay.io](https://quay.io/repository/nginx/nginx-ingress) or [build your own image](https://github.com/nginxinc/kubernetes-ingress/tree/main/docs/content/installation/building-ingress-controller-image.md). | [Build your own image](https://github.com/nginxinc/kubernetes-ingress/tree/main/docs/content/installation/building-ingress-controller-image.md). | [Manifests](https://github.com/nginxinc/kubernetes-ingress/tree/main/deployments). [Helm chart](https://github.com/nginxinc/kubernetes-ingress/tree/main/charts/nginx-ingress). | [Documentation](https://github.com/nginxinc/kubernetes-ingress/tree/main/docs/content). [Examples](https://github.com/nginxinc/kubernetes-ingress/tree/main/examples). |

## SBOM (Software Bill of Materials)
Expand Down
8 changes: 4 additions & 4 deletions charts/nginx-ingress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ The steps you should follow depend on the Helm release name:

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`
4. Update the `selectorLabels: {}` field in the `values.yaml` file located at `/kubernates-ingress/charts/nginx-ingress`
with the copied `Selector` value.

```shell
Expand Down Expand Up @@ -281,9 +281,9 @@ reviewing its events:

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`
4. Update the `selectorLabels: {}` field in the `values.yaml` file located at `/kubernates-ingress/charts/nginx-ingress`
with the copied `Selector` value.

```shell
Expand Down
10 changes: 5 additions & 5 deletions charts/nginx-ingress/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@
},
"tag": {
"type": "string",
"default": "2.3.1",
"default": "3.3.2",
"title": "The tag of the Ingress Controller image",
"examples": [
"2.3.1"
"3.3.2"
]
},
"digest": {
Expand Down Expand Up @@ -345,7 +345,7 @@
"examples": [
{
"repository": "nginx/nginx-ingress",
"tag": "2.3.1",
"tag": "3.3.2",
"pullPolicy": "IfNotPresent"
}
]
Expand Down Expand Up @@ -1318,7 +1318,7 @@
"customPorts": [],
"image": {
"repository": "nginx/nginx-ingress",
"tag": "2.3.1",
"tag": "3.3.2",
"digest": "",
"pullPolicy": "IfNotPresent"
},
Expand Down Expand Up @@ -1689,7 +1689,7 @@
"customPorts": [],
"image": {
"repository": "nginx/nginx-ingress",
"tag": "2.3.1",
"tag": "3.3.2",
"digest": "",
"pullPolicy": "IfNotPresent"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/content/configuration/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The Ingress Controller requires a service account which is configured using RBAC
We strongly recommend using the [RBAC configuration](https://github.com/nginxinc/kubernetes-ingress/blob/v3.3.2/deployments/rbac/rbac.yaml) provided in our standard deployment configuration. It is configured with the least amount of privilege required for the Ingress Controller to work.

We strongly recommend inspecting the RBAC configuration for [Manifests](https://github.com/nginxinc/kubernetes-ingress/blob/v3.3.2/deployments/rbac/rbac.yaml)
or for [Helm](https://github.com/nginxinc/kubernetes-ingress/blob/v3.3.2/deployments/helm-chart/templates/rbac.yaml) to understand what access the Ingress Controller service account has and to which resources. For example, by default the service account has access to all Secret resources in the cluster.
or for [Helm](https://github.com/nginxinc/kubernetes-ingress/blob/v3.3.2/charts/nginx-ingress/templates/rbac.yaml) to understand what access the Ingress Controller service account has and to which resources. For example, by default the service account has access to all Secret resources in the cluster.

### Certificates and Privacy Keys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ The steps you should follow depend on the Helm release name:
Selector: app=nginx-ingress-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-nginx-ingress}
```
Expand Down Expand Up @@ -247,11 +247,11 @@ The steps you should follow depend on the Helm release name:
Selector: app=<helm_release_name>-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: <helm_release_name>-nginx-ingress}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/troubleshooting/troubleshoot-common.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ controller:
nginxplus: plus
image:
repository: nginx/nginx-ingress
tag: 3.3.0
tag: 3.3.2
# NGINX Configmap
config:
entries:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/tutorials/custom-listen-ports.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-resources/service-insight/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b056696

Please sign in to comment.