|
| 1 | +#! /usr/bin/env bash |
| 2 | +# Copyright 2025 The Kubernetes Authors. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -o errexit |
| 17 | + |
| 18 | +TAG=${1} |
| 19 | +GIT_TAG_OPTIONS=${GIT_TAG_OPTIONS:-} |
| 20 | +GIT_COMMIT_OPTIONS=${GIT_COMMIT_OPTIONS:-} |
| 21 | +GIT_COMMIT_PUSH=${GIT_COMMITS_PUSH:-} |
| 22 | +GIT_COMMIT_REMOTE=${GIT_COMMITS_REMOTE:-} |
| 23 | + |
| 24 | +echo "Updating all modules ..." |
| 25 | + |
| 26 | +find "providers" "examples" -name go.mod | while read -r GOMOD; do |
| 27 | + module=$(dirname "${GOMOD}") |
| 28 | + if [ "$(git tag -l "${module}/${TAG}")" ]; then |
| 29 | + echo "${module}/${LTAG} already exists. Do you really need to run this script?" |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | + |
| 33 | + pushd "${module}" |
| 34 | + go get "sigs.k8s.io/multicluster-runtime@${TAG}" |
| 35 | + go mod tidy |
| 36 | + popd |
| 37 | +done |
| 38 | + |
| 39 | +echo "Creating release commit ..." |
| 40 | + |
| 41 | +git add ./providers/ ./examples/ |
| 42 | +git commit -m "Prepare release for sigs.k8s.io/multicluster-runtime@${TAG}" ${GIT_COMMIT_OPTIONS} |
| 43 | + |
| 44 | +if [ -n "$GIT_COMMIT_PUSH" ] && [ -n "$GIT_COMMIT_REMOTE" ]; then |
| 45 | + echo "Pushing release commit to ${GIT_COMMIT_REMOTE} ..." |
| 46 | + git push "${GIT_COMMIT_REMOTE}" |
| 47 | +fi |
| 48 | + |
| 49 | +echo "Creating release tags ..." |
| 50 | + |
| 51 | +# set up main tag |
| 52 | +git tag -am "${TAG}" "${TAG}" ${GIT_TAG_OPTIONS} |
| 53 | +echo "Created tag ${TAG}." |
| 54 | + |
| 55 | +# create provider and example tags |
| 56 | +find "providers" "examples" -name go.mod | while read -r GOMOD; do |
| 57 | + module=$(dirname "${GOMOD}") |
| 58 | + git tag -am "${module}/${TAG}" "${module}/${TAG}" ${GIT_TAG_OPTIONS} |
| 59 | + echo "Created tag ${module}/${TAG}." |
| 60 | +done |
| 61 | + |
| 62 | +echo "" |
| 63 | +echo "Tags have been successfully created on the release commit." |
| 64 | +echo "As a next step, open a PR for your branch in kubernetes-sigs/multicluster-runtime." |
| 65 | +echo "Once the PR has been merged, push all git tags created above. |
0 commit comments