+ LOGS_URL=${LOGS_URL%/} # strip any trailing '/'
+ PYPI_PROJECT="${PYPI_PROJECT:-None}"
+ if [[ $PYPI_PROJECT == "None" ]]; then
+ PYPI_PROJECT="$(yq -er .pypi_project "$release_file")"
+ fi
+ PYTHON_VERSION="${PYTHON_VERSION:-None}"
+ if [[ $PYTHON_VERSION == "None" ]]; then
+ PYTHON_VERSION="$(yq -er .python_version "$release_file")"
+ fi
+ VERSION="${VERSION:-None}"
+ if [[ $VERSION == "None" ]]; then
+ VERSION="$(yq -er .version "$release_file")"
+ 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"
+}
+
+verify_schema(){
+ echo "INFO: Verifying $release_file schema."
+ lftools schema verify "$release_file" "$RELEASE_SCHEMA"
+}
+
+verify_version(){
+ # Verify allowed patterns "v#.#.#" or "#.#.#" aka SemVer
+ echo "INFO: Verifying version string $VERSION"
+ allowed_version_regex="^((v?)([0-9]+)\.([0-9]+)\.([0-9]+))$"
+ if [[ $VERSION =~ $allowed_version_regex ]]; then
+ echo "INFO: The version $VERSION is a valid semantic version"
+ else
+ echo "INFO: The version $VERSION is not a semantic valid version"
+ echo "INFO: Allowed versions are \"v#.#.#\" or \"#.#.#\" aka SemVer"
+ echo "INFO: See https://semver.org/ for more details on SemVer"
+ exit 1
+ fi
+}
+
+verify_version_match_release(){
+ wget -P /tmp "${LOGS_URL}/"console.log.gz
+ echo "INFO: Comparing version $VERSION with log snippet from maven-stage:"
+ if zgrep "Successfully uploaded" /tmp/console.log.gz | grep "$VERSION"; then
+ echo "INFO: version $VERSION matches maven-stage artifacts"
+ else
+ echo "ERROR: Defined version in release file does not match staging repo artifacts version to be released"
+ echo " Please make sure maven-stage job selected as candidate and release version are correct"
+ exit 1
+ fi
+}
+
+# check prerequisites to detect mistakes in the release YAML file
+verify_pypi_match_release(){
+ wget -q -P /tmp "${LOGS_URL}/"console.log.gz
+ echo "INFO: Searching for strings >$PYPI_PROJECT< and >$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
+}
+
+# sigul is only available on Centos
+# TODO: write tag_github function
+tag(){
+ # Import public signing key
+ gpg --import "$SIGNING_PUBKEY"
+ if git tag -v "$VERSION"; then
+ echo "OK: Repo already tagged $VERSION Continuting to release"
+ else
+ echo "INFO: Repo has not yet been tagged $VERSION"
+ git tag -am "${PROJECT//\//-} $VERSION" "$VERSION"
+ sigul --batch -c "$SIGUL_CONFIG" sign-git-tag "$SIGUL_KEY" "$VERSION" < "$SIGUL_PASSWORD"
+ echo "INFO: Showing latest signature for $PROJECT:"
+ echo "INFO: git tag -v $VERSION"
+ git tag -v "$VERSION"
+
+ ########## Merge Part ##############
+ if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
+ echo "INFO: Running merge, pushing tag"
+ gerrit_ssh=$(echo "$GERRIT_URL" | awk -F"/" '{print $3}')
+ git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/"$PROJECT"
+ git config user.name "$RELEASE_USERNAME"
+ git config user.email "$RELEASE_EMAIL"
+ echo -e "Host $gerrit_ssh\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
+ chmod 600 ~/.ssh/config
+ git push origin "$VERSION"
+ fi
+ fi
+}
+
+nexus_release(){
+ for staging_url in $(zcat "$PATCH_DIR"/staging-repo.txt.gz | awk -e '{print $2}'); do
+ # extract the domain name from URL
+ NEXUS_URL=$(echo "$staging_url" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
+ echo "INFO: NEXUS_URL: $NEXUS_URL"
+ # extract the staging repo from URL
+ STAGING_REPO=${staging_url#*repositories/}
+ echo "INFO: Running Nexus Verify"
+ lftools nexus release -v --server https://"$NEXUS_URL" "$STAGING_REPO"
+ echo "INFO: Merge will run:"
+ echo "lftools nexus release --server https://$NEXUS_URL $STAGING_REPO"
+ done
+
+ #Run the loop twice, to catch errors on either nexus repo
+ if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
+ for staging_url in $(zcat "$PATCH_DIR"/staging-repo.txt.gz | awk -e '{print $2}'); do
+ NEXUS_URL=$(echo "$staging_url" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
+ STAGING_REPO=${staging_url#*repositories/}
+ echo "INFO: Promoting $STAGING_REPO on $NEXUS_URL."
+ lftools nexus release --server https://"$NEXUS_URL" "$STAGING_REPO"
+ done
+ fi
+}
+
+container_release_file(){
+ echo "INFO: Processing container release"
+ local lfn_umbrella
+ lfn_umbrella="$(echo "$GERRIT_HOST" | awk -F"." '{print $2}')"