github.com/kubernetes-incubator/kube-aws@v0.16.4/contrib/bump-version (about)

     1  #!/bin/bash
     2  #
     3  # This script will go through each of the tracked files in this repo and update
     4  # the CURRENT_VERSION to the TARGET_VERSION. This is meant as a helper - but
     5  # probably should still double-check the changes are correct
     6  
     7  if [ $# -ne 1 ] || [ `expr $1 : ".*.*"` == 0 ]; then
     8      echo "USAGE: $0 <target-version>"
     9      echo "  example: $0 'v1.11.3'"
    10      exit 1
    11  fi
    12  
    13  # the version needs to be published, see https://quay.io/repository/coreos/hyperkube?tag=latest&tab=tags
    14  CURRENT_VERSION=${CURRENT_VERSION:-"v1.11.3"}
    15  TARGET_VERSION=${1}
    16  
    17  CURRENT_VERSION_BASE=${CURRENT_VERSION%%_*}
    18  TARGET_VERSION_BASE=${TARGET_VERSION%%_*}
    19  
    20  CURRENT_VERSION_SEMVER=${CURRENT_VERSION/_/+}
    21  TARGET_VERSION_SEMVER=${TARGET_VERSION/_/+}
    22  
    23  GIT_ROOT=$(git rev-parse --show-toplevel)
    24  
    25  cd $GIT_ROOT
    26  TRACKED=($(git grep -F "${CURRENT_VERSION_BASE}"| awk -F : '{print $1}' | sort -u))
    27  for i in "${TRACKED[@]}"; do
    28      echo Updating $i
    29      if [ "$(uname -s)" == "Darwin" ]; then
    30          sed -i "" "s/${CURRENT_VERSION}/${TARGET_VERSION}/g" $i
    31          sed -i "" "s/${CURRENT_VERSION_SEMVER}/${TARGET_VERSION_SEMVER}/g" $i
    32          sed -i "" "s/${CURRENT_VERSION_BASE}/${TARGET_VERSION_BASE}/g" $i
    33      else
    34          sed -i "s/${CURRENT_VERSION}/${TARGET_VERSION}/g" $i
    35          sed -i "s/${CURRENT_VERSION_SEMVER}/${TARGET_VERSION_SEMVER}/g" $i
    36          sed -i "s/${CURRENT_VERSION_BASE}/${TARGET_VERSION_BASE}/g" $i
    37      fi
    38  done