|  | 
|  | 1 | +#!/bin/bash | 
|  | 2 | + | 
|  | 3 | +# Copyright 2025 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. | 
|  | 16 | + | 
|  | 17 | + | 
|  | 18 | +# Helper script to tag a release when the version/TAG_VERSION file is updated. | 
|  | 19 | + | 
|  | 20 | +set -o errexit | 
|  | 21 | +set -o nounset | 
|  | 22 | +set -o pipefail | 
|  | 23 | + | 
|  | 24 | +VERSION=$(cat version/TAG_VERSION) | 
|  | 25 | + | 
|  | 26 | +if [[ ! "${VERSION}" =~ ^([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then | 
|  | 27 | +  echo "Version ${VERSION} must be 'X.Y.Z', 'X.Y.Z-alpha.N', or 'X.Y.Z-beta.N'" | 
|  | 28 | +  exit 1 | 
|  | 29 | +fi | 
|  | 30 | + | 
|  | 31 | +# Store the minor version for use in the branch creation. | 
|  | 32 | +# We want to capture this value now before we do another regex match. | 
|  | 33 | +MINOR=${BASH_REMATCH[1]} | 
|  | 34 | +RELEASE_BRANCH="release-${MINOR}" | 
|  | 35 | + | 
|  | 36 | +if [ "$(git tag -l "v${VERSION}")" ]; then | 
|  | 37 | +  echo "Tag v${VERSION} already exists" | 
|  | 38 | +  exit 0 | 
|  | 39 | +fi | 
|  | 40 | + | 
|  | 41 | +echo "Tagging Release ${VERSION}" | 
|  | 42 | +git tag -a -m "Release ${VERSION}" "v${VERSION}" | 
|  | 43 | +git push origin "v${VERSION}" | 
|  | 44 | + | 
|  | 45 | +# Create the release branch automatically on the first beta release. | 
|  | 46 | +if [[ ! "${VERSION}" =~ .0-beta.1$ ]]; then | 
|  | 47 | +  exit 0 | 
|  | 48 | +fi | 
|  | 49 | + | 
|  | 50 | +echo "Creating Release Branch ${RELEASE_BRANCH}" | 
|  | 51 | +git branch "${RELEASE_BRANCH}" | 
|  | 52 | +git push origin "${RELEASE_BRANCH}" | 
0 commit comments