+ LOGS_URL=${LOGS_URL%/} # strip any trailing '/'
+ if [[ -z ${PYPI_PROJECT:-} ]]; then
+ PYPI_PROJECT=$(yq -r ".pypi_project" "$release_file")
+ fi
+ if [[ -z ${PYTHON_VERSION:-} ]]; then
+ PYTHON_VERSION=$(yq -r ".python_version" "$release_file")
+ fi
+ if [[ -z ${VERSION:-} ]]; then
+ VERSION=$(yq -r ".version" "$release_file")
+ fi
+ if [[ -z ${GIT_TAG:-} ]]; then
+ if grep -q "git_tag" "$release_file" ; then
+ GIT_TAG=$(yq -r ".git_tag" "$release_file")
+ else
+ GIT_TAG="$VERSION"
+ fi
+ fi
+
+ # Continuing displaying Release Information (pypi)
+ printf "\t%-30s\n" RELEASE_PYPI_INFO:
+ printf "\t%-30s %s\n" LOG_DIR: "$LOG_DIR"
+ printf "\t%-30s %s\n" LOGS_URL: "$LOGS_URL"
+ printf "\t%-30s %s\n" PYPI_INDEX: "$PYPI_INDEX" # from job configuration
+ printf "\t%-30s %s\n" PYPI_PROJECT: "$PYPI_PROJECT"
+ printf "\t%-30s %s\n" PYTHON_VERSION: "$PYTHON_VERSION"
+ printf "\t%-30s %s\n" VERSION: "$VERSION"
+ printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
+}
+
+set_variables_packagecloud(){
+ echo "INFO: Setting packagecloud variables"
+ if [[ -z ${VERSION:-} ]]; then
+ VERSION=$(yq -r ".version" "$release_file")
+ fi
+ if [[ -z ${GIT_TAG:-} ]]; then
+ if grep -q "git_tag" $release_file ; then
+ GIT_TAG=$(yq -r ".git_tag" "$release_file")
+ else
+ GIT_TAG="$VERSION"
+ fi
+ fi
+ if [[ -z ${LOG_DIR:-} ]]; then
+ LOG_DIR=$(yq -r ".log_dir" "$release_file")
+ fi
+ if [[ -z ${REF:-} ]]; then
+ REF=$(yq -r ".ref" "$release_file")
+ fi
+ if [[ -z ${PACKAGE_NAME:-} ]]; then
+ PACKAGE_NAME=$(yq -r ".package_name" "$release_file")
+ fi
+ logs_url="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
+ logs_url=${logs_url%/} # strip any trailing '/'
+
+ printf "\t%-30s %s\n" PACKAGE_NAME: "$PACKAGE_NAME"
+ printf "\t%-30s %s\n" LOG_DIR: "$LOG_DIR"
+ printf "\t%-30s %s\n" LOGS_URL: "$logs_url"
+ printf "\t%-30s %s\n" GERRIT_REF_TO_TAG: "$REF"
+ printf "\t%-30s %s\n" VERSION: "$VERSION"
+ printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
+}
+
+verify_schema(){
+ echo "INFO: Verifying $release_file against schema $release_schema"
+ lftools schema verify "$release_file" "$release_schema"
+}
+
+verify_version(){
+ # Verify allowed patterns "#.#.#" (SemVer) or "v#.#.#"
+ echo "INFO: Verifying version $VERSION"
+ allowed_version_regex="^((v?)([0-9]+)\.([0-9]+)\.([0-9]+))$"
+ if [[ $VERSION =~ $allowed_version_regex ]]; then
+ echo "INFO: The version $VERSION is valid"
+ else
+ echo "ERROR: The version $VERSION is not valid"
+ echo "ERROR: Valid versions are \"#.#.#\" (SemVer) or \"v#.#.#\""
+ echo "ERROR: See https://semver.org/ for more details on SemVer"
+ exit 1
+ fi
+}
+
+verify_version_match_release(){
+ echo "INFO: Fetching console log from $LOGS_URL"
+ wget -P /tmp "${LOGS_URL}/"console.log.gz
+ echo "INFO: Searching for uploaded step and version $VERSION in job log"
+ if zgrep "Successfully uploaded" /tmp/console.log.gz | grep "$VERSION"; then
+ echo "INFO: found expected strings in job log"
+ else
+ echo "ERROR: Defined version in release file does not match staging repo artifacts version to be released"
+ echo "ERROR: Please make sure maven stage job log dir and release version are both correct"
+ exit 1
+ fi
+}
+
+# check prerequisites to detect mistakes in the release YAML file
+verify_pypi_match_release(){
+ echo "INFO: Fetching console log from $LOGS_URL"
+ wget -q -P /tmp "${LOGS_URL}/"console.log.gz
+ echo "INFO: Searching for uploaded step, project $PYPI_PROJECT and version $VERSION in job log"
+ # pypi-upload.sh generates success message with file list
+ if zgrep -i "uploaded" /tmp/console.log.gz | grep "$PYPI_PROJECT" | grep "$VERSION" ; then
+ echo "INFO: found expected strings in job log"
+ else
+ echo "ERROR: failed to find expected strings in job log"
+ exit 1
+ fi
+}
+
+verify_packagecloud_match_release(){
+ echo "INFO: Fetching console log from $logs_url"
+ wget -q -P /tmp "${logs_url}/"console.log.gz
+ echo "INFO: Searching for uploaded step, package name $PACKAGE_NAME and version $VERSION in job log"
+ if zgrep -E "Pushing.*$PACKAGE_NAME.*$VERSION.*success\!" /tmp/console.log.gz; then
+ echo "INFO: found expected strings in job log"
+ else
+ echo "ERROR: failed to find expected strings in job log"
+ exit 1
+ fi
+}