sigs.k8s.io/controller-tools@v0.15.1-0.20240515195456-85686cb69316/hack/envtest/update-releases.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright 2024 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  set -o nounset
    18  set -o pipefail
    19  set -x
    20  
    21  ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
    22  
    23  if [ -z "${KUBERNETES_VERSION}" ]; then
    24    echo "Missing KUBERNETES_VERSION environment variable"
    25    exit 1
    26  fi
    27  
    28  # Create the releases.yaml file in hack/envtest if it does not exist
    29  if [ ! -f "${ROOT}"/envtest-releases.yaml ]; then
    30    echo "releases:" > "${ROOT}"/envtest-releases.yaml
    31  fi
    32  
    33  # Add the newly built Kubernetes version to the releases.yaml file with yq as an object key under releases
    34  yq eval ".releases += {\"${KUBERNETES_VERSION}\": {}}" -i "${ROOT}"/envtest-releases.yaml
    35  
    36  for file in "${ROOT}"/out/*.tar.gz; do
    37    file_name=$(basename "${file}")
    38    file_hash=$(awk '{ print $1 }' < "${file}.sha512")
    39    self_link=https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-${KUBERNETES_VERSION}/${file_name}
    40  
    41    yq eval \
    42      ".releases[\"${KUBERNETES_VERSION}\"] += {\"${file_name}\": {\"hash\": \"${file_hash}\", \"selfLink\": \"${self_link}\"}}" \
    43      -i "${ROOT}"/envtest-releases.yaml
    44  done