Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version #324

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions tools/carto-download-customer-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ CUSTOMER_PACKAGE_NAME_PREFIX="carto-selfhosted-${SELFHOSTED_MODE}-customer-packa
CUSTOMER_PACKAGE_FOLDER="customer-package"
##########################################

function _check_gsutil_file()
{
file_path=${1}
gsutil -q stat $file_path
return $?
}

function _check_deps()
{
for DEP in ${DEPENDENCIES} ; do
Expand Down Expand Up @@ -157,12 +164,24 @@ if ( gcloud auth activate-service-account "${CARTO_SERVICE_ACCOUNT_EMAIL}" --key
fi

# Get latest customer package version
CUSTOMER_PACKAGE_FILE_LATEST="$(gsutil ls "gs://${CLIENT_STORAGE_BUCKET}/${CUSTOMER_PACKAGE_FOLDER}/${CUSTOMER_PACKAGE_NAME_PREFIX}-${CLIENT_ID}-*-*-*.zip")"
CUSTOMER_PACKAGE_FILE_LATEST="$(gsutil ls "gs://${CLIENT_STORAGE_BUCKET}/${CUSTOMER_PACKAGE_FOLDER}/${CUSTOMER_PACKAGE_NAME_PREFIX}-${CLIENT_ID}-*-*-*.zip" | grep -v '\-rc\-')"
SELFHOSTED_VERSION_LATEST="$(echo "${CUSTOMER_PACKAGE_FILE_LATEST}" | grep -Eo "${CLIENT_ID}-[0-9]+-[0-9]+-[0-9]+")"
SELFHOSTED_VERSION_LATEST="${SELFHOSTED_VERSION_LATEST/#${CLIENT_ID}-}"

_info "latest version: ${SELFHOSTED_VERSION_LATEST}"

# Check if exist the latest stable release
STABLE_CUSTOMER_PACKAGE_DOWNLOAD_URL="gs://${CLIENT_STORAGE_BUCKET}/${CUSTOMER_PACKAGE_FOLDER}/${CUSTOMER_PACKAGE_NAME_PREFIX}-${CLIENT_ID}-${SELFHOSTED_VERSION_LATEST}.zip"
if _check_gsutil_file ${STABLE_CUSTOMER_PACKAGE_DOWNLOAD_URL}
then
CUSTOMER_PACKAGE_DOWNLOAD_URL=${STABLE_CUSTOMER_PACKAGE_DOWNLOAD_URL}
_info "download file: ${CUSTOMER_PACKAGE_DOWNLOAD_URL}"
else
_error "stable version ${SELFHOSTED_VERSION_LATEST} not found: ${STABLE_CUSTOMER_PACKAGE_DOWNLOAD_URL}" 404
fi

# Double-check customer package download URI
[[ "${CUSTOMER_PACKAGE_FILE_LATEST}" != "gs://${CLIENT_STORAGE_BUCKET}/${CUSTOMER_PACKAGE_FOLDER}/${CUSTOMER_PACKAGE_NAME_PREFIX}-${CLIENT_ID}-${SELFHOSTED_VERSION_LATEST}.zip" ]] && \
[[ "${CUSTOMER_PACKAGE_FILE_LATEST}" != "${CUSTOMER_PACKAGE_DOWNLOAD_URL}" ]] && \
_error "customer package download URI mismatch" 7

# Download package
Expand Down
Loading