github.com/cloudberrydb/gpbackup@v1.0.3-0.20240118031043-5410fd45eed6/ci/scripts/update-metadata.bash (about) 1 #!/bin/bash 2 3 set -ex 4 5 mkdir workspace/files-to-upload 6 7 # Add binary tarball to pivnet upload, excluding version strings 8 cp github_release_components_rc/*.gz /tmp/ 9 pushd /tmp 10 mkdir untarred 11 tar xzf *.gz -C untarred 12 popd 13 cp /tmp/untarred/bin_gpbackup.tar.gz workspace/files-to-upload/ 14 15 cp gpbackup/ci/pivnet_release/metadata.yml workspace/ 16 tar xzf gppkgs/gpbackup-gppkgs.tar.gz -C workspace/files-to-upload/ 17 GPBACKUP_VERSION=$(cat workspace/files-to-upload/gpbackup_version) 18 19 # the same gpbackup version will exist in the tile version string 20 # if this release only includes updates to components outside of 21 # gpbackup itself (e.g. plugins, manager) 22 pushd pivnet_release_cache 23 PRV_TILE_VERSION=$(echo v-* | tr '+' '-' | cut -d- -f1-2) 24 CURR_TILE_VERSION=$(echo "v-${GPBACKUP_VERSION}" | tr '+' '-' | cut -d- -f1-2) 25 if [[ -f ${CURR_TILE_VERSION} ]]; then 26 echo "Release already exists on Pivnet" 27 exit 1 28 else 29 # detect the release type 30 PRV_MAJOR=$(echo ${PRV_TILE_VERSION:2} | cut -d. -f1) 31 PRV_MINOR=$(echo ${PRV_TILE_VERSION:2} | cut -d. -f2) 32 PRV_PATCH=$(echo ${PRV_TILE_VERSION:2} | cut -d. -f3 | sed -r "s/([0-9]+).*/\1/") 33 CURR_MAJOR=$(echo ${CURR_TILE_VERSION:2} | cut -d. -f1) 34 CURR_MINOR=$(echo ${CURR_TILE_VERSION:2} | cut -d. -f2) 35 CURR_PATCH=$(echo ${CURR_TILE_VERSION:2} | cut -d. -f3 | sed -r "s/([0-9]+).*/\1/") 36 if [[ "$PRV_MAJOR" != "$CURR_MAJOR" ]] ; then 37 RELEASE_TYPE="Major" 38 elif [[ "$PRV_MINOR" != "$CURR_MINOR" ]] ; then 39 RELEASE_TYPE="Minor" 40 elif [[ "$PRV_PATCH" != "$CURR_PATCH" ]] ; then 41 RELEASE_TYPE="Maintenance" 42 else 43 echo "Unable to determine release type." 44 exit 1 45 fi 46 fi 47 48 TILE_RELEASE_VERSION=${CURR_TILE_VERSION:2} 49 touch ../workspace/v-${TILE_RELEASE_VERSION} 50 popd 51 52 if test ! -f gpbackup-release-license/open_source_license_VMware_Tanzu_Greenplum_Backup_and_Restore_${CURR_MAJOR}.${CURR_MINOR}.*.txt ; then 53 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 54 exit 1 55 fi 56 cp gpbackup-release-license/open_source_license_VMware_Tanzu_Greenplum_Backup_and_Restore_*.txt workspace/files-to-upload/ 57 58 # NOTE: We must use the Pivnet Release Version because we cannot upload files with the same name in different tile releases 59 DDBOOST_PLUGIN_VERSION=$(cat workspace/files-to-upload/ddboost_plugin_version) 60 sed -i "s/<DDBOOST_PLUGIN_VERSION>/${DDBOOST_PLUGIN_VERSION}/g" workspace/metadata.yml 61 S3_PLUGIN_VERSION=$(cat workspace/files-to-upload/s3_plugin_version) 62 sed -i "s/<S3_PLUGIN_VERSION>/${S3_PLUGIN_VERSION}/g" workspace/metadata.yml 63 BMAN_VERSION=$(cat workspace/files-to-upload/gpbackup_manager_version) 64 sed -i "s/<BMAN_VERSION>/${BMAN_VERSION}/g" workspace/metadata.yml 65 sed -i "s/<TILE_RELEASE_VERSION>/${TILE_RELEASE_VERSION}/g" workspace/metadata.yml 66 sed -i "s/<GPBAR_VERSION>/${TILE_RELEASE_VERSION}/g" workspace/metadata.yml 67 OSL_FILENAME=$(basename -- gpbackup-release-license/open_source_license_VMware_Tanzu_Greenplum_Backup_and_Restore_*.txt) 68 sed -i "s/<OSL_FILENAME>/${OSL_FILENAME}/g" workspace/metadata.yml 69 sed -i "s/<RELEASE_TYPE>/${RELEASE_TYPE} Release/g" workspace/metadata.yml 70 71 # Calculate end of support date (last day of the month 18 months from now) 72 future_date_18_month=$(date -d "+19 month" +%Y-%m-01) 73 END_OF_SUPPORT_DATE=$(date -d "$future_date_18_month - 1 day" +%Y-%m-%d) 74 sed -i "s/<END_OF_SUPPORT_DATE>/${END_OF_SUPPORT_DATE}/g" workspace/metadata.yml 75 76 # The URL adjusts based on major/minor version 77 REL_NOTES_VERSION=$(echo ${TILE_RELEASE_VERSION//./-} | cut -d- -f1,2) 78 sed -i "s/<REL_NOTES_VERSION>/${REL_NOTES_VERSION}/g" workspace/metadata.yml 79 80 cat workspace/metadata.yml 81 pushd workspace/files-to-upload 82 # rename files to match the name inside metadata.yml 83 for filename in *.gppkg; do 84 newFilename=$(sed -e "s/gpbackup_tools-[+0-9a-z.]*/pivotal_greenplum_backup_restore-${TILE_RELEASE_VERSION}/" -e "s/RHEL/rhel/" -e "s/SLES/sles/" <<< "$filename") 85 if ! [ "$filename" == "$newFilename" ]; then 86 mv "$filename" "$newFilename" 87 fi 88 done 89 # rename binary tarball 90 mv "bin_gpbackup.tar.gz" "pivotal_greenplum_backup_restore-${TILE_RELEASE_VERSION}.tar.gz" 91 popd 92 93 echo ${TILE_RELEASE_VERSION} > workspace/tile_release_version 94 rm workspace/files-to-upload/*_version 95 # We must remove unnecessary GP7 artifacts from the pivnet upload directory 96 rm workspace/files-to-upload/*-gp7-* 97 ls -l workspace/files-to-upload