| 1 |
#!/bin/bash |
| 2 |
#Copyright 2022 The gRPC 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 |
# This script can be used to manually update the specific versions of Bazel |
| 17 |
# tested by the Bazel distribtests and advertised as supported in documentation. |
| 18 |
# This will update the supported_versions.txt file, which will be templated into |
| 19 |
# the bazel_support.md document. |
| 20 |
|
| 21 |
# This script selects the latest patch release of the two most recent major |
| 22 |
# versions of Bazel. If you want to include other versions in the set of |
| 23 |
# supported versions, then you will need to manually edit the ifle. |
| 24 |
|
| 25 |
set -xeuo pipefail |
| 26 |
|
| 27 |
cd "$(dirname "$0")/../.." |
| 28 |
|
| 29 |
# The number of most recent supported major Bazel versions. |
| 30 |
SUPPORT_RANGE="2" |
| 31 |
|
| 32 |
# Retrieve all git tags from the Bazel git repo. |
| 33 |
TAGS=$(git ls-remote --tags [email protected]:bazelbuild/bazel.git | awk '{print $2;}' | sed 's|refs/tags/||g') |
| 34 |
|
| 35 |
# Find the n most recent major versions. |
| 36 |
MAJOR_VERSIONS=$(echo "$TAGS" | egrep '^[0-9]+\.[0-9]+\.[0-9]+$' | cut -d'.' -f1 | sort -r | uniq | head -n"$SUPPORT_RANGE") |
| 37 |
|
| 38 |
SUPPORTED_VERSIONS="" |
| 39 |
|
| 40 |
# For each major version selected, find the most recent patch release. |
| 41 |
while read -r MAJOR_VERSION; do |
| 42 |
LATEST_PATCH=$(echo "$TAGS" | egrep "^${MAJOR_VERSION}\.[0-9]+\.[0-9]+$" | sort -nr | head -n1) |
| 43 |
SUPPORTED_VERSIONS="$SUPPORTED_VERSIONS$LATEST_PATCH\n" |
| 44 |
done<<<"$MAJOR_VERSIONS" |
| 45 |
|
| 46 |
printf "$SUPPORTED_VERSIONS" | tee bazel/supported_versions.txt |