github.com/verrazzano/verrazzano@v1.7.0/release/scripts/compare_crds.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Copyright (c) 2021, 2022, Oracle and/or its affiliates.
     4  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     5  #
     6  
     7  # Compare all CRD differences between two commits, tags, etc.
     8  
     9  usage() {
    10      cat <<EOM
    11    Shows all CRD differences between two git tags, commits, etc.
    12  
    13    Usage:
    14      $(basename $0) <release version> <from> <to>
    15  
    16    Example:
    17      $(basename $0) 1.0.3
    18  
    19    This script should be run from the git repository containing the bits to release. "release version" is required.
    20    "from" and "to" can be tags, commits, etc. "from" defaults to the most recent version tag for the previous release and "to" defaults to HEAD.
    21  EOM
    22      exit 0
    23  }
    24  
    25  [ "$1" == "-h" ] && { usage; }
    26  
    27  VERSION=$1
    28  FROM=$2
    29  TO=${3:-HEAD}
    30  
    31  # Default to the latest tag from the prior release
    32  if [[ -z "$FROM" ]]; then
    33    MAJOR=$(echo ${VERSION} | cut -d. -f 1)
    34    MINOR=$(echo ${VERSION} | cut -d. -f 2)
    35    PATCH=$(echo ${VERSION} | cut -d. -f 3)
    36  
    37    git fetch --tags
    38  
    39    if [ "${MINOR}" == "0" ] && [ "${PATCH}" == "0" ]; then
    40      # Major version release - find the latest tag matching the previous major release
    41      PREV=v$(expr ${MAJOR} - "1").
    42    else
    43      if [ "${PATCH}" == "0" ]; then
    44        # Minor version release - find the latest tag matching the previous minor release
    45        PREV=v${MAJOR}.$(expr ${MINOR} - "1").
    46      else
    47        # Patch version release - find the latest tag matching the current major and minor version
    48        PREV=v${MAJOR}.${MINOR}.
    49      fi
    50    fi
    51  
    52    FROM=$(git tag --sort=taggerdate | grep ${PREV} | tail -1)
    53  fi
    54  
    55  echo "Showing all CRD differences between $FROM and $TO"
    56  echo ""
    57  
    58  SCRIPT_DIR=$(dirname "$0")
    59  git --no-pager diff --exit-code $FROM $TO -- `find $SCRIPT_DIR/../.. -type f -path '*/crds/*.yaml'`