github.com/greenplum-db/gpbackup@v0.0.0-20240517212602-89daab1885b3/ci/scripts/update-metadata.bash (about)

     1  #!/bin/bash
     2  
     3  set -ex
     4  
     5  export TANZUNET_REFRESH_TOKEN=${TANZUNET_REFRESH_TOKEN}
     6  mkdir workspace/files-to-upload
     7  
     8  ##############################
     9  # Add binary tarballs to pivnet upload, excluding version strings
    10  mkdir /tmp/rhel7
    11  mkdir /tmp/rhel8
    12  mkdir /tmp/rhel9
    13  mkdir /tmp/ubuntu
    14  
    15  cp release_components_rhel7/*.gz /tmp/rhel7
    16  cp release_components_rhel8/*.gz /tmp/rhel8
    17  cp release_components_rhel9/*.gz /tmp/rhel9
    18  cp release_components_ubuntu/*.gz /tmp/ubuntu
    19  
    20  pushd /tmp
    21      mkdir untarred_rhel7
    22      mkdir untarred_rhel8
    23      mkdir untarred_rhel9
    24      mkdir untarred_ubuntu
    25  
    26      tar xzf rhel7/*.gz -C untarred_rhel7
    27      tar xzf rhel8/*.gz -C untarred_rhel8
    28      tar xzf rhel9/*.gz -C untarred_rhel9
    29      tar xzf ubuntu/*.gz -C untarred_ubuntu
    30  popd
    31  
    32  cp /tmp/untarred_rhel7/bin_gpbackup.tar.gz workspace/files-to-upload/bin_gpbackup-rhel7.tar.gz
    33  cp /tmp/untarred_rhel8/bin_gpbackup.tar.gz workspace/files-to-upload/bin_gpbackup-rhel8.tar.gz
    34  cp /tmp/untarred_rhel9/bin_gpbackup.tar.gz workspace/files-to-upload/bin_gpbackup-rhel9.tar.gz
    35  cp /tmp/untarred_ubuntu/bin_gpbackup.tar.gz workspace/files-to-upload/bin_gpbackup-ubuntu.tar.gz
    36  ##############################
    37  
    38  ##############################
    39  cp gpbackup/ci/pivnet_release/metadata.yml workspace/
    40  tar xzf gppkgs/gpbackup-gppkgs.tar.gz -C workspace/files-to-upload/
    41  GPBACKUP_VERSION=$(cat workspace/files-to-upload/gpbackup_version)
    42  
    43  # the same gpbackup version will exist in the tile version string
    44  # if this release only includes updates to components outside of
    45  # gpbackup itself (e.g. plugins, manager)
    46  pushd pivnet_release_cache
    47    PRV_TILE_VERSION=$(echo v-* | tr '+' '-' | cut -d- -f1-2)
    48    CURR_TILE_VERSION=$(echo "v-${GPBACKUP_VERSION}" | tr '+' '-' | cut -d- -f1-2)
    49    if [[ -f ${CURR_TILE_VERSION} ]]; then
    50        echo "Release already exists on Pivnet"
    51        exit 1
    52    else
    53      # detect the release type
    54      PRV_MAJOR=$(echo ${PRV_TILE_VERSION:2} | cut -d. -f1)
    55      PRV_MINOR=$(echo ${PRV_TILE_VERSION:2} | cut -d. -f2)
    56      PRV_PATCH=$(echo ${PRV_TILE_VERSION:2} | cut -d. -f3 | sed -r "s/([0-9]+).*/\1/")
    57      CURR_MAJOR=$(echo ${CURR_TILE_VERSION:2} | cut -d. -f1)
    58      CURR_MINOR=$(echo ${CURR_TILE_VERSION:2} | cut -d. -f2)
    59      CURR_PATCH=$(echo ${CURR_TILE_VERSION:2} | cut -d. -f3 | sed -r "s/([0-9]+).*/\1/")
    60      if [[ "$PRV_MAJOR" != "$CURR_MAJOR" ]] ; then
    61        RELEASE_TYPE="Major"
    62      elif [[ "$PRV_MINOR" != "$CURR_MINOR" ]] ; then
    63        RELEASE_TYPE="Minor"
    64      elif [[ "$PRV_PATCH" != "$CURR_PATCH" ]] ; then
    65        RELEASE_TYPE="Maintenance"
    66      else
    67        echo "Unable to determine release type."
    68        exit 1
    69      fi
    70    fi
    71  
    72    TILE_RELEASE_VERSION=${CURR_TILE_VERSION:2}
    73    touch ../workspace/v-${TILE_RELEASE_VERSION}
    74  popd
    75  
    76  if test ! -f gpbackup-release-license/open_source_license_VMware_Greenplum_Backup_and_Restore_${CURR_MAJOR}.${CURR_MINOR}.*.txt ; then
    77    echo "License file for gpbackup version ${CURR_MAJOR}.${CURR_MINOR}.* does not exist in resource.\n Ensure the OSL is properly uploaded to the GCS bucket prior to pushing to pivnet." 1>&2
    78    exit 1
    79  fi
    80  cp gpbackup-release-license/open_source_license_VMware_Greenplum_Backup_and_Restore_*.txt workspace/files-to-upload/
    81  
    82  # NOTE: We must use the Pivnet Release Version because we cannot upload files with the same name in different tile releases
    83  DDBOOST_PLUGIN_VERSION=$(cat workspace/files-to-upload/ddboost_plugin_version)
    84  sed -i "s/<DDBOOST_PLUGIN_VERSION>/${DDBOOST_PLUGIN_VERSION}/g" workspace/metadata.yml
    85  S3_PLUGIN_VERSION=$(cat workspace/files-to-upload/s3_plugin_version)
    86  sed -i "s/<S3_PLUGIN_VERSION>/${S3_PLUGIN_VERSION}/g" workspace/metadata.yml
    87  BMAN_VERSION=$(cat workspace/files-to-upload/gpbackup_manager_version)
    88  sed -i "s/<BMAN_VERSION>/${BMAN_VERSION}/g" workspace/metadata.yml
    89  sed -i "s/<TILE_RELEASE_VERSION>/${TILE_RELEASE_VERSION}/g" workspace/metadata.yml
    90  sed -i "s/<GPBAR_VERSION>/${TILE_RELEASE_VERSION}/g" workspace/metadata.yml
    91  OSL_FILENAME=$(basename -- gpbackup-release-license/open_source_license_VMware_Greenplum_Backup_and_Restore_*.txt)
    92  sed -i "s/<OSL_FILENAME>/${OSL_FILENAME}/g" workspace/metadata.yml
    93  sed -i "s/<RELEASE_TYPE>/${RELEASE_TYPE} Release/g" workspace/metadata.yml
    94  
    95  # Calculate end of support date (last day of the month 18 months from now)
    96  future_date_18_month=$(date -d "+19 month" +%Y-%m-01)
    97  END_OF_SUPPORT_DATE=$(date -d "$future_date_18_month - 1 day" +%Y-%m-%d)
    98  sed -i "s/<END_OF_SUPPORT_DATE>/${END_OF_SUPPORT_DATE}/g" workspace/metadata.yml
    99  
   100  # The URL adjusts based on major/minor version
   101  REL_NOTES_VERSION=$(echo ${TILE_RELEASE_VERSION} | cut -d. -f1,2)
   102  sed -i "s/<REL_NOTES_VERSION>/${REL_NOTES_VERSION}/g" workspace/metadata.yml
   103  
   104  cat workspace/metadata.yml
   105  pushd workspace/files-to-upload
   106    # rename files to match the name inside metadata.yml
   107    for filename in *.gppkg; do
   108      newFilename=$(sed -e "s/gpbackup_tools-[+0-9a-z.]*/greenplum_backup_restore-${TILE_RELEASE_VERSION}/" -e "s/RHEL/rhel/" -e "s/SLES/sles/" <<< "$filename")
   109      if ! [ "$filename" == "$newFilename" ]; then
   110        mv "$filename" "$newFilename"
   111      fi
   112    done
   113  
   114    # rename binary tarballs, to match the name inside metadata.yml
   115    for filename in *.tar.gz; do
   116        newFilename="${filename/bin_gpbackup/greenplum_backup_restore-${TILE_RELEASE_VERSION}}"
   117        if ! [ "$filename" == "$newFilename" ]; then
   118            mv "$filename" "$newFilename"
   119        fi
   120    done
   121  popd
   122  
   123  echo ${TILE_RELEASE_VERSION} > workspace/tile_release_version
   124  rm workspace/files-to-upload/*_version
   125  ls -l workspace/files-to-upload
   126  
   127  push_to_tanzunet() {
   128  	set -ex
   129  	chmod a+x tanzunet_client/gp-tanzunet-client
   130  	tanzunet_client/gp-tanzunet-client upload -g "${TILE_RELEASE_VERSION}"\
   131                                         -m "workspace/metadata.yml" -s "workspace/files-to-upload"\
   132                                         --tanzunet-endpoint "https://network.tanzu.vmware.com" --tanzunet-slug "greenplum-backup-restore"\
   133                                         --debug
   134  }
   135  
   136  if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
   137  	push_to_tanzunet
   138  fi