|
1 |
| -# This file is intended to document release steps. |
2 |
| -# Verify each step's result before calling the next command. |
3 |
| -# It is documented here with the intention of being automated |
4 |
| -# as a shell script later. |
| 1 | +#!/bin/bash |
5 | 2 |
|
6 |
| -echo 'git clean -xdf' |
7 |
| -echo 'python setup.py sdist' |
8 |
| -echo 'python setup.py bdist_wheel --universal' |
9 |
| -echo 'twine upload dist/* -r https://upload.pypi.org/legacy/ -u kubernetes' |
| 3 | +# Copyright 2021 The Kubernetes Authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
10 | 16 |
|
| 17 | +# Workflow |
| 18 | +# 1. [master branch] update existing snapshot (include API change for a new alpha/beta/GA |
| 19 | +# release) |
| 20 | +# - add a new snapshot or reuse the existing snapshot, the latter means either |
| 21 | +# API change happened in a k8s patch release, or we want to include some new |
| 22 | +# python / python-base change in the release note |
| 23 | +# - API change w/ release notes |
| 24 | +# - master change w/ release notes |
| 25 | +# - submodule change w/ release notes |
| 26 | +# 2. [master branch] create new snapshot (include API change for a new alpha release) |
| 27 | +# - add a new snapshot or reuse the existing snapshot, the latter means either |
| 28 | +# API change happened in a k8s patch release, or we want to include some new |
| 29 | +# python / python-base change in the release note |
| 30 | +# - API change w/ release notes |
| 31 | +# - master change w/ release notes |
| 32 | +# - submodule change w/ release notes |
| 33 | +# 3. [release branch] create a new release |
| 34 | +# - pull master |
| 35 | +# - it's possible that master has new changes after the latest snaphost, |
| 36 | +# update CHANGELOG accordingly |
| 37 | +# - for generated file, resolve conflict by committing the master version |
| 38 | +# - abort if a snapshot doesn't exists |
| 39 | +# - generate client change, abort if API change is detected |
| 40 | +# - CHANGELOG: latest snapshot becomes the release, create a new snapshot |
| 41 | +# section that reflect the master branch state |
| 42 | +# - README: add the release to README |
| 43 | +# - an extra PR to update CHANGELOG and README in master in sync with this new |
| 44 | +# release |
| 45 | +# |
| 46 | +# Difference between 1&2: API change release notes |
| 47 | +# |
| 48 | +# TODO(roycaihw): |
| 49 | +# - add user input validation |
| 50 | +# - add function input validaiton (release/version strings start with 'v' or not) |
| 51 | +# - automatically send a PR; provide useful links for review |
| 52 | +# - master branch diff: https://github.com/kubernetes-client/python/compare/commit1..commit2 |
| 53 | +# - python base diff: https://github.com/kubernetes-client/python-base/compare/commit1..commit2 |
| 54 | +# - Kubernetes changelog, e.g. https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.18.md |
| 55 | +# - add debug log |
| 56 | +# - add a sentence about "changes since {last release}". In most cases our |
| 57 | +# releases should be sequential. This script (the workflow above) is based on |
| 58 | +# this assumption, and we should make the release note clear about that. |
| 59 | +# |
| 60 | +# Usage: |
| 61 | + |
| 62 | +set -o errexit |
| 63 | +set -o nounset |
| 64 | +set -o pipefail |
| 65 | + |
| 66 | +repo_root="$(git rev-parse --show-toplevel)" |
| 67 | +declare -r repo_root |
| 68 | +cd "${repo_root}" |
| 69 | + |
| 70 | +source scripts/util/changelog.sh |
| 71 | +source scripts/util/kube_changelog.sh |
| 72 | + |
| 73 | +old_client_version=$(python3 "scripts/constants.py" CLIENT_VERSION) |
| 74 | +old_k8s_api_version=$(util::changelog::get_k8s_api_version "v$old_client_version") |
| 75 | +KUBERNETES_BRANCH=${KUBERNETES_BRANCH:-$(python3 "scripts/constants.py" KUBERNETES_BRANCH)} |
| 76 | +CLIENT_VERSION=${CLIENT_VERSION:-$(python3 "scripts/constants.py" CLIENT_VERSION)} |
| 77 | +DEVELOPMENT_STATUS=${DEVELOPMENT_STATUS:-$(python3 "scripts/constants.py" DEVELOPMENT_STATUS)} |
| 78 | + |
| 79 | +# get Kubernetes API Version |
| 80 | +new_k8s_api_version=$(util::kube_changelog::find_latest_patch_version $KUBERNETES_BRANCH) |
| 81 | +echo "Old Kubernetes API Version: $old_k8s_api_version" |
| 82 | +echo "New Kubernetes API Version: $new_k8s_api_version" |
| 83 | + |
| 84 | +sed -i "s/^KUBERNETES_BRANCH =.*$/KUBERNETES_BRANCH = \"$KUBERNETES_BRANCH\"/g" scripts/constants.py |
| 85 | +sed -i "s/^CLIENT_VERSION =.*$/CLIENT_VERSION = \"$CLIENT_VERSION\"/g" scripts/constants.py |
| 86 | +sed -i "s/^DEVELOPMENT_STATUS =.*$/DEVELOPMENT_STATUS = \"$DEVELOPMENT_STATUS\"/g" scripts/constants.py |
| 87 | +git commit -am "update version constants for $CLIENT_VERSION release" |
| 88 | + |
| 89 | +util::changelog::update_release_api_version $CLIENT_VERSION $old_client_version $new_k8s_api_version |
| 90 | + |
| 91 | +# get API change release notes since $old_k8s_api_version. |
| 92 | +# NOTE: $old_k8s_api_version may be one-minor-version behind $KUBERNETES_BRANCH, e.g. |
| 93 | +# KUBERNETES_BRANCH=release-1.19 |
| 94 | +# old_k8s_api_version=1.18.17 |
| 95 | +# when we bump the minor version for the snapshot in the master branch. We |
| 96 | +# don't need to collect release notes in release-1.18, because any API |
| 97 | +# change in 1.18.x (x > 17) must be a cherrypick that is already included in |
| 98 | +# release-1.19. |
| 99 | +# TODO(roycaihw): not all Kubernetes API changes modify the OpenAPI spec. |
| 100 | +# Download the patch and skip if the spec is not modified. Also we want want to |
| 101 | +# look at other k/k sections like "deprecation" |
| 102 | +release_notes=$(util::kube_changelog::get_api_changelog "$KUBERNETES_BRANCH" "$old_k8s_api_version") |
| 103 | +if [[ -n "$release_notes" ]]; then |
| 104 | + util::changelog::write_changelog v$CLIENT_VERSION "### API Change" "$release_notes" |
| 105 | +fi |
| 106 | + |
| 107 | +git commit -m "update changelog" |
| 108 | + |
| 109 | +# run client generator |
| 110 | +scripts/update-client.sh |
| 111 | + |
| 112 | +rm -r kubernetes/test/ |
| 113 | +git add . |
| 114 | +git commit -m "temporary generated commit" |
| 115 | +scripts/apply-hotfixes.sh |
| 116 | +git reset HEAD~2 |
| 117 | +# custom object API is hosted in gen repo. Commit API change separately for |
| 118 | +# easier review |
| 119 | +if [[ -z "$(git diff kubernetes/client/api/custom_objects_api.py)" ]]; then |
| 120 | + git add kubernetes/client/api/custom_objects_api.py |
| 121 | + git commit -m "generated client change for custom_objects" |
| 122 | +fi |
| 123 | +git add kubernetes/docs kubernetes/client/api/ kubernetes/client/models/ kubernetes/swagger.json.unprocessed scripts/swagger.json |
| 124 | +git commit -m "generated API change" |
| 125 | +git add . |
| 126 | +git commit -m "generated client change" |
0 commit comments