@@ -67,35 +67,36 @@ set -o errexit
6767set -o nounset
6868set -o pipefail
6969
70- # used by the client generator: https://github.com/kubernetes-client/gen/blob/729332ad08f0f4d98983b7beb027e2f657236ef9/openapi/openapi-generator/client-generator.sh#L52
70+ # Set constants used by the client generator.
7171export USERNAME=kubernetes
7272
73+ # Set up utilities.
7374repo_root=" $( git rev-parse --show-toplevel) "
7475declare -r repo_root
7576cd " ${repo_root} "
7677
7778source scripts/util/changelog.sh
7879source scripts/util/kube_changelog.sh
7980
80- old_client_version=$( python3 " scripts/constants.py" CLIENT_VERSION)
81- old_k8s_api_version=$( util::changelog::get_k8s_api_version " v$old_client_version " )
81+ # Read user inputs or values locally.
8282KUBERNETES_BRANCH=${KUBERNETES_BRANCH:- $(python3 " scripts/constants.py" KUBERNETES_BRANCH)}
8383CLIENT_VERSION=${CLIENT_VERSION:- $(python3 " scripts/constants.py" CLIENT_VERSION)}
8484DEVELOPMENT_STATUS=${DEVELOPMENT_STATUS:- $(python3 " scripts/constants.py" DEVELOPMENT_STATUS)}
8585
86- # get Kubernetes API Version
86+ # Get Kubernetes API versions
87+ old_client_version=$( python3 " scripts/constants.py" CLIENT_VERSION)
88+ old_k8s_api_version=$( util::changelog::get_k8s_api_version " v$old_client_version " )
8789new_k8s_api_version=$( util::kube_changelog::find_latest_patch_version $KUBERNETES_BRANCH )
8890echo " Old Kubernetes API Version: $old_k8s_api_version "
8991echo " New Kubernetes API Version: $new_k8s_api_version "
9092
93+ # Update version constants
9194sed -i " s/^KUBERNETES_BRANCH =.*$/KUBERNETES_BRANCH = \" $KUBERNETES_BRANCH \" /g" scripts/constants.py
9295sed -i " s/^CLIENT_VERSION =.*$/CLIENT_VERSION = \" $CLIENT_VERSION \" /g" scripts/constants.py
9396sed -i " s/^DEVELOPMENT_STATUS =.*$/DEVELOPMENT_STATUS = \" $DEVELOPMENT_STATUS \" /g" scripts/constants.py
9497git commit -am " update version constants for $CLIENT_VERSION release"
9598
96- util::changelog::update_release_api_version $CLIENT_VERSION $old_client_version $new_k8s_api_version
97-
98- # get API change release notes since $old_k8s_api_version.
99+ # Update CHANGELOG with API change release notes since $old_k8s_api_version.
99100# NOTE: $old_k8s_api_version may be one-minor-version behind $KUBERNETES_BRANCH, e.g.
100101# KUBERNETES_BRANCH=release-1.19
101102# old_k8s_api_version=1.18.17
@@ -106,30 +107,34 @@ util::changelog::update_release_api_version $CLIENT_VERSION $old_client_version
106107# TODO(roycaihw): not all Kubernetes API changes modify the OpenAPI spec.
107108# Download the patch and skip if the spec is not modified. Also we want to
108109# look at other k/k sections like "deprecation"
110+ util::changelog::update_release_api_version $CLIENT_VERSION $old_client_version $new_k8s_api_version
109111release_notes=$( util::kube_changelog::get_api_changelog " $KUBERNETES_BRANCH " " $old_k8s_api_version " )
110112if [[ -n " $release_notes " ]]; then
111113 util::changelog::write_changelog v$CLIENT_VERSION " ### API Change" " $release_notes "
112114fi
113-
114115git commit -am " update changelog"
115116
116- # run client generator
117+ # Re-generate the client
117118scripts/update-client.sh
118119
120+ # Apply hotfixes
119121rm -r kubernetes/test/
120122git add .
121123git commit -m " temporary generated commit"
122124scripts/apply-hotfixes.sh
123125git reset HEAD~2
124- # custom object API is hosted in gen repo. Commit API change separately for
125- # easier review
126+
127+ # Custom object API is hosted in gen repo. Commit custom object API change
128+ # separately for easier review
126129if [[ -n " $( git diff kubernetes/client/api/custom_objects_api.py) " ]]; then
127130 git add kubernetes/client/api/custom_objects_api.py
128131 git commit -m " generated client change for custom_objects"
129132fi
133+ # Check if there is any API change, then commit
130134git add kubernetes/docs kubernetes/client/api/ kubernetes/client/models/ kubernetes/swagger.json.unprocessed scripts/swagger.json
131- # verify if there are staged changes, then commit
132135git diff-index --quiet --cached HEAD || git commit -m " generated API change"
136+ # Commit everything else
133137git add .
134138git commit -m " generated client change"
139+
135140echo " Release finished successfully."
0 commit comments