X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Frelease-job.sh;h=e01d3a93c89d73c0202cf9025c924f63a846bd72;hb=8901fe0bee2fecb6b32accffd9f952d46da59a38;hp=9ff67994434e90a56ed3daa80e2c640d6a5bc835;hpb=4b1496d42d0b44c650fc700234d30ae35dc4176d;p=releng%2Fglobal-jjb.git diff --git a/shell/release-job.sh b/shell/release-job.sh index 9ff67994..e01d3a93 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -21,7 +21,31 @@ lf-activate-venv lftools pip idna==2.9 lftools jsonschema twine yq readline python -m pip --version python -m pip freeze -#Functions. +########################## +# Set Variables Functions. +########################## + +set_variables_artifact(){ + echo "INFO: Setting artifact 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 ${REF:-} ]]; then + REF=$(yq -r ".ref" "$release_file") + fi + + printf "\t%-30s\n" RELEASE_ARTIFACT_INFO: + 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" +} set_variables_common(){ echo "INFO: Setting common variables" @@ -35,13 +59,13 @@ set_variables_common(){ release_files=$(git diff-tree -m --no-commit-id -r "$GIT_COMMIT" "$GIT_COMMIT^1" \ --name-only -- "releases/" ".releases/") if (( $(grep -c . <<<"$release_files") > 1 )); then - echo "INFO: RELEASE FILES ARE AS FOLLOWS: $release_files" - echo "ERROR: Adding multiple release files in the same commit" - echo "ERROR: OR rename/amend/delete of existing files is not supported." - exit 1 + echo "INFO: RELEASE FILES ARE AS FOLLOWS: $release_files" + echo "ERROR: Adding multiple release files in the same commit" + echo "ERROR: OR rename/amend/delete of existing files is not supported." + exit 1 else - release_file="$release_files" - echo "INFO: RELEASE FILE: $release_files" + release_file="$release_files" + echo "INFO: RELEASE FILE: $release_files" fi else echo "INFO: This job is built with parameters, no release file needed." @@ -73,7 +97,7 @@ set_variables_common(){ TAG_RELEASE="${TAG_RELEASE:-None}" if [[ $TAG_RELEASE == "None" ]]; then - if grep -q "tag_release" $release_file ; then + if grep -q "tag_release" "$release_file"; then TAG_RELEASE=$(yq -r .tag_release "$release_file") else TAG_RELEASE=true @@ -83,7 +107,7 @@ set_variables_common(){ # Displaying Release Information (Common variables) printf "\t%-30s\n" RELEASE_ENVIRONMENT_INFO: printf "\t%-30s %s\n" RELEASE_FILE: "$release_file" - printf "\t%-30s %s\n" LOGS_SERVER: "$LOGS_SERVER" + printf "\t%-30s %s\n" LOGS_SERVER: "${LOGS_SERVER:-None}" printf "\t%-30s %s\n" CDN_URL: "${CDN_URL:-None}" printf "\t%-30s %s\n" NEXUS_PATH: "$NEXUS_PATH" printf "\t%-30s %s\n" JENKINS_HOSTNAME: "$JENKINS_HOSTNAME" @@ -95,6 +119,40 @@ set_variables_common(){ printf "\t%-30s %s\n" OVERRIDE_SEMVER_REGEX: "${OVERRIDE_SEMVER_REGEX:-None}" } +set_variables_container(){ + echo "INFO: Setting container variables" + if [[ -z ${VERSION:-} ]]; then + VERSION=$(yq -r ".container_release_tag" "$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 grep -q "container_pull_registry" "$release_file" ; then + CONTAINER_PULL_REGISTRY=$(yq -r ".container_pull_registry" "$release_file") + fi + if grep -q "container_push_registry" "$release_file" ; then + CONTAINER_PUSH_REGISTRY=$(yq -r ".container_push_registry" "$release_file") + fi + # Make sure both pull and push registries are defined + if [ -z ${CONTAINER_PULL_REGISTRY+x} ] || [ -z ${CONTAINER_PUSH_REGISTRY+x} ]; then + echo "ERROR: CONTAINER_PULL_REGISTRY and CONTAINER_PUSH_REGISTRY need to be defined" + exit 1 + fi + ref=$(yq -r ".ref" "$release_file") + + # Continuing displaying Release Information (Container) + printf "\t%-30s\n" RELEASE_CONTAINER_INFO: + printf "\t%-30s %s\n" CONTAINER_RELEASE_TAG: "$VERSION" + printf "\t%-30s %s\n" CONTAINER_PULL_REGISTRY: "$CONTAINER_PULL_REGISTRY" + printf "\t%-30s %s\n" CONTAINER_PUSH_REGISTRY: "$CONTAINER_PUSH_REGISTRY" + printf "\t%-30s %s\n" GIT_REF_TO_TAG: "$ref" + printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG" +} + set_variables_maven(){ echo "INFO: Setting maven variables" if [[ -z ${VERSION:-} ]]; then @@ -119,37 +177,33 @@ set_variables_maven(){ printf "\t%-30s %s\n" LOGS_URL: "$logs_url" } -set_variables_container(){ - echo "INFO: Setting container variables" +set_variables_packagecloud(){ + echo "INFO: Setting packagecloud variables" if [[ -z ${VERSION:-} ]]; then - VERSION=$(yq -r ".container_release_tag" "$release_file") + VERSION=$(yq -r ".version" "$release_file") fi if [[ -z ${GIT_TAG:-} ]]; then - if grep -q "git_tag" "$release_file" ; then + if grep -q "git_tag" "$release_file"; then GIT_TAG=$(yq -r ".git_tag" "$release_file") else GIT_TAG="$VERSION" fi - fi - if grep -q "container_pull_registry" "$release_file" ; then - CONTAINER_PULL_REGISTRY=$(yq -r ".container_pull_registry" "$release_file") fi - if grep -q "container_push_registry" "$release_file" ; then - CONTAINER_PUSH_REGISTRY=$(yq -r ".container_push_registry" "$release_file") + if [[ -z ${LOG_DIR:-} ]]; then + LOG_DIR=$(yq -r ".log_dir" "$release_file") fi - # Make sure both pull and push registries are defined - if [ -z ${CONTAINER_PULL_REGISTRY+x} ] || [ -z ${CONTAINER_PUSH_REGISTRY+x} ]; then - echo "ERROR: CONTAINER_PULL_REGISTRY and CONTAINER_PUSH_REGISTRY need to be defined" - exit 1 + 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 - ref=$(yq -r ".ref" "$release_file") - # Continuing displaying Release Information (Container) - printf "\t%-30s\n" RELEASE_CONTAINER_INFO: - printf "\t%-30s %s\n" CONTAINER_RELEASE_TAG: "$VERSION" - printf "\t%-30s %s\n" CONTAINER_PULL_REGISTRY: "$CONTAINER_PULL_REGISTRY" - printf "\t%-30s %s\n" CONTAINER_PUSH_REGISTRY: "$CONTAINER_PUSH_REGISTRY" - printf "\t%-30s %s\n" GIT_REF_TO_TAG: "$ref" + 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" GIT_REF_TO_TAG: "$REF" + printf "\t%-30s %s\n" VERSION: "$VERSION" printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG" } @@ -174,7 +228,7 @@ set_variables_pypi(){ else GIT_TAG="$VERSION" fi - fi + fi # Continuing displaying Release Information (pypi) printf "\t%-30s\n" RELEASE_PYPI_INFO: @@ -187,34 +241,33 @@ set_variables_pypi(){ 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 - - 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" GIT_REF_TO_TAG: "$REF" - printf "\t%-30s %s\n" VERSION: "$VERSION" - printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG" +########################## +# Verify Schema Functions. +########################## + +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 +} + +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_schema(){ @@ -223,12 +276,14 @@ verify_schema(){ } verify_version(){ - # Override the regex for projects that do not follow https://semver.org OVERRIDE_SEMVER_REGEX="${OVERRIDE_SEMVER_REGEX:-None}" if [[ $OVERRIDE_SEMVER_REGEX == "None" ]]; then # Use the semver regex taken from https://github.com/fsaintjacques/semver-tool - semver_regex="^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" + pat1="(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)" + pat2="(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)" + pat3="(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)" + semver_regex="^[vV]?${pat1}(\-${pat2}(\.${pat2})*)?${pat3}?$" else semver_regex="${OVERRIDE_SEMVER_REGEX}" fi @@ -260,38 +315,17 @@ verify_version_match_release(){ 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 -} +##################### +# Tag Repo Functions. +##################### # sigul is only available on Centos # TODO: write tag-github-repo function tag-git-repo(){ if [[ $TAG_RELEASE == false ]]; then - echo "INFO: Skipping code repo tag" - return + echo "INFO: Skipping code repo tag" + return fi if [[ -z ${GERRIT_URL:-} ]]; then @@ -331,34 +365,53 @@ tag-git-repo(){ fi git config user.name "$RELEASE_USERNAME" git config user.email "$RELEASE_EMAIL" + echo "INFO: push tag: $GIT_TAG" git push origin "$GIT_TAG" + # Check if sentinal file exists + if [[ -f .testhash ]]; then + echo "INFO: push code bundle" + git push origin "HEAD:${GERRIT_REFSPEC}" + fi fi fi } -nexus_release(){ - echo "INFO: Processing 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 +############################### +# Release Processing Functions. +############################### - #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 +artifact_release_file(){ + echo "INFO: Processing artifact release" + mkdir artifacts + ORG=$(echo "$NEXUS_URL" | awk -F'.' '{print $2}') + + for namequoted in $(yq '.artifacts[].name' "$release_file"); do + pathquoted=$(yq ".artifacts[] |select(.name==$namequoted) |.path" "$release_file") + + #Remove extra yaml quotes + name="${namequoted#\"}" + name="${name%\"}" + path="${pathquoted#\"}" + path="${path%\"}" + + echo "$name" + echo "$path" + echo "INFO: Merge will post artifact: $name" + # Attempt to pull from releases to see if the artifact has been released. + if "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"$name"; then + echo "INFO: $name is already released as version:$VERSION, Continuing..." + else + echo "INFO: $name not found in releases, release will be prepared. Continuing..." + wget "${path}"/"${name}" -o artifacts/"${name}" + if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then + #lftools sign sigul artifacts + # shellcheck disable=SC2261 + curl -v -u : --upload-file \ + "${NEXUS_URL}"/content/repositories/releases/org/"${ORG}"/"${VERSION}"/"${name}" \; + fi + echo "#########################" + fi + done } container_release_file(){ @@ -367,8 +420,8 @@ container_release_file(){ local lfn_umbrella lfn_umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')" - for namequoted in $(yq '.containers[].name' $release_file); do - versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" $release_file) + for namequoted in $(yq '.containers[].name' "$release_file"); do + versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" "$release_file") #Remove extra yaml quotes name="${namequoted#\"}" @@ -390,8 +443,16 @@ container_release_file(){ echo "docker tag $container_image_id $CONTAINER_PUSH_REGISTRY/$lfn_umbrella/$name:$VERSION" echo "docker push $CONTAINER_PUSH_REGISTRY/$lfn_umbrella/$name:$VERSION" if [[ "$JOB_NAME" =~ "merge" ]]; then + curl -O -L "https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64" + sudo mv cosign-linux-amd64 /usr/local/bin/cosign + sudo chmod +x /usr/local/bin/cosign + export COSIGN_PASSWORD docker tag "$container_image_id" "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION" docker push "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION" + image_sha=$(docker images --no-trunc --quiet \ + "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION") + image_digest="$CONTAINER_PUSH_REGISTRY/$lfn_umbrella/$name@$image_sha" + cosign sign -y --key "$COSIGN_PRIVATE_KEY" "$image_digest" fi echo "#########################" fi @@ -412,13 +473,84 @@ maven_release_file(){ gunzip taglist.log.gz cat "$PATCH_DIR"/taglist.log popd - git checkout "$(awk '{print $NF}' "$PATCH_DIR/taglist.log")" + + # compare if the commit sha1 from taglist is the same origin/${GERRIT_BRANCH} + # ensure that the tag lands on the target branch + # forward from the tagging point, then a spur commit is created + # for the tag + taghash="$(awk '{print $NF}' "$PATCH_DIR/taglist.log")" + # shellcheck disable=SC2046 + if [ "${taghash}" = $(git rev-parse "origin/${GERRIT_BRANCH}") ]; then + git checkout "origin/${GERRIT_BRANCH}" + # sentinal file + touch .testhash + else + git checkout "${taghash}" + fi + git fetch "$PATCH_DIR/${PROJECT//\//-}.bundle" git merge --ff-only FETCH_HEAD + # print last few changes to see how the bundle is applied + git log --graph --all --decorate --pretty=oneline -n10 nexus_release tag-git-repo } +nexus_release(){ + echo "INFO: Processing 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 +} + +packagecloud_promote(){ + echo "INFO: Preparing to promote $1..." + promote_url="https://packagecloud.io$(curl --netrc-file ~/packagecloud_api \ + --silent https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \ + | yq -r .[].promote_url)" + echo "INFO: Promoting $1 from staging to release" + curl --netrc-file ~/packagecloud_api -X POST -F \ + destination="$2/release" "$promote_url" \ + | echo "INFO: Promoted package location: \ + https://packagecloud.io$(yq -r .package_html_url)" + git checkout "$REF" + tag-git-repo +} + +packagecloud_verify(){ + echo "INFO: Verifying $1 exists in staging..." + if [[ $1 == $(curl --netrc-file ~/packagecloud_api --silent \ + https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \ + | yq -r .[].filename) ]]; then + echo "INFO: $1 exists in staging!" + echo "INFO: Existing package location: https://packagecloud.io$(curl \ + --netrc-file ~/packagecloud_api --silent \ + https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \ + | yq -r .[].package_html_url)" + else + echo "ERROR: $1 does not exist in staging" + exit 1 + fi +} + # calls pip to download binary and source distributions from the specified index, # which requires a recent-in-2019 version. Uploads the files it received. pypi_release_file(){ @@ -464,59 +596,30 @@ pypi_release_file(){ tag-git-repo } -packagecloud_verify(){ - echo "INFO: Verifying $1 exists in staging..." - if [[ $1 == $(curl --netrc-file ~/packagecloud_api --silent \ - https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \ - | yq -r .[].filename) ]]; then - echo "INFO: $1 exists in staging!" - echo "INFO: Existing package location: https://packagecloud.io$(curl \ - --netrc-file ~/packagecloud_api --silent \ - https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \ - | yq -r .[].package_html_url)" - else - echo "ERROR: $1 does not exist in staging" - exit 1 - fi -} - -packagecloud_promote(){ - echo "INFO: Preparing to promote $1..." - promote_url="https://packagecloud.io$(curl --netrc-file ~/packagecloud_api \ - --silent https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \ - | yq -r .[].promote_url)" - echo "INFO: Promoting $1 from staging to release" - curl --netrc-file ~/packagecloud_api -X POST -F \ - destination="$2/release" "$promote_url" \ - | echo "INFO: Promoted package location: \ - https://packagecloud.io$(yq -r .package_html_url)" - git checkout "$REF" - tag-git-repo -} - ############################## End Function Declarations ################################ # Set common environment variables set_variables_common # Determine the type of release: +# - artifact, release-artifact-schema.yaml # - container, release-container-schema.yaml # - maven, release-schema.yaml +# - packagecloud, release-packagecloud-schema.yaml # - pypi, release-pypi-schema.yaml case $DISTRIBUTION_TYPE in - maven) + artifact) if $USE_RELEASE_FILE ; then - release_schema="release-schema.yaml" + release_schema="release-artifact-schema.yaml" echo "INFO: Fetching schema $release_schema" - wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/$release_schema + wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/${release_schema} verify_schema fi - set_variables_maven + set_variables_artifact verify_version - verify_version_match_release - maven_release_file + artifact_release_file ;; container) @@ -531,17 +634,17 @@ case $DISTRIBUTION_TYPE in container_release_file ;; - pypi) + maven) if $USE_RELEASE_FILE ; then - release_schema="release-pypi-schema.yaml" + release_schema="release-schema.yaml" echo "INFO: Fetching schema $release_schema" - wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/${release_schema} + wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/$release_schema verify_schema fi - set_variables_pypi + set_variables_maven verify_version - verify_pypi_match_release - pypi_release_file + verify_version_match_release + maven_release_file ;; packagecloud) @@ -554,7 +657,7 @@ case $DISTRIBUTION_TYPE in fi set_variables_packagecloud verify_packagecloud_match_release - for name in $(yq -r '.packages[].name' $release_file); do + for name in $(yq -r '.packages[].name' "$release_file"); do package=$name packagecloud_verify "$package" "$packagecloud_account" if [[ "$JOB_NAME" =~ "merge" ]] && ! $DRY_RUN; then @@ -563,6 +666,19 @@ case $DISTRIBUTION_TYPE in done ;; + pypi) + if $USE_RELEASE_FILE ; then + release_schema="release-pypi-schema.yaml" + echo "INFO: Fetching schema $release_schema" + wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/${release_schema} + verify_schema + fi + set_variables_pypi + verify_version + verify_pypi_match_release + pypi_release_file + ;; + *) echo "ERROR: distribution_type: $DISTRIBUTION_TYPE not supported" exit 1