1c1b5707f92577a71ede27e32c7b6824cf07d426
[releng/global-jjb.git] / shell / release-job.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> release-job.sh"
12 set -eu -o pipefail
13
14 # shellcheck disable=SC1090
15 source ~/lf-env.sh
16
17 # Version controlled by JJB_VERSION
18 lf-activate-venv lftools pip idna==2.8 lftools jsonschema twine yq readline
19
20 # show installed versions
21 python -m pip --version
22 python -m pip freeze
23
24 #Functions.
25
26 set_variables_common(){
27     echo "INFO: Setting common variables"
28     if [[ -z ${LOGS_SERVER:-} ]]; then
29         echo "ERROR: LOGS_SERVER not defined"
30         exit 1
31     fi
32     NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/"
33     # Verify if using release file or parameters
34     if $USE_RELEASE_FILE ; then
35         release_files=$(git diff-tree -m --no-commit-id -r "$GIT_COMMIT" "$GIT_COMMIT^1" \
36             --name-only -- "releases/" ".releases/")
37         if (( $(grep -c . <<<"$release_files") > 1 )); then
38           echo "INFO: RELEASE FILES ARE AS FOLLOWS: $release_files"
39           echo "ERROR: Adding multiple release files in the same commit"
40           echo "ERROR: OR rename/amend/delete of existing files is not supported."
41           exit 1
42         else
43           release_file="$release_files"
44           echo "INFO: RELEASE FILE: $release_files"
45         fi
46     else
47         echo "INFO: This job is built with parameters, no release file needed."
48         release_file="None"
49     fi
50
51     # Jenkins parameter drop-down defaults DISTRIBUTION_TYPE to None
52     # in the contain/maven release job; get value from release yaml.
53     # Packagecloud and PyPI jobs set the appropriate value.
54     DISTRIBUTION_TYPE="${DISTRIBUTION_TYPE:-None}"
55     if [[ $DISTRIBUTION_TYPE == "None" ]]; then
56         if ! DISTRIBUTION_TYPE=$(yq -r ".distribution_type" "$release_file"); then
57             echo "ERROR: Failed to get distribution_type from $release_file"
58             exit 1
59         fi
60     fi
61
62     PATCH_DIR=$(mktemp -d)
63
64     TAG_RELEASE="${TAG_RELEASE:-None}"
65     if [[ $TAG_RELEASE == "None" ]]; then
66         if grep -q "tag_release" $release_file ; then
67             TAG_RELEASE=$(yq -r .tag_release "$release_file")
68         else
69             TAG_RELEASE=true
70         fi
71     fi
72
73     # Displaying Release Information (Common variables)
74     printf "\t%-30s\n" RELEASE_ENVIRONMENT_INFO:
75     printf "\t%-30s %s\n" RELEASE_FILE: "$release_file"
76     printf "\t%-30s %s\n" LOGS_SERVER: "$LOGS_SERVER"
77     printf "\t%-30s %s\n" NEXUS_PATH: "$NEXUS_PATH"
78     printf "\t%-30s %s\n" JENKINS_HOSTNAME: "$JENKINS_HOSTNAME"
79     printf "\t%-30s %s\n" SILO: "$SILO"
80     printf "\t%-30s %s\n" PROJECT: "$PROJECT"
81     printf "\t%-30s %s\n" PROJECT-DASHED: "${PROJECT//\//-}"
82     printf "\t%-30s %s\n" TAG_RELEASE: "$TAG_RELEASE"
83     printf "\t%-30s %s\n" DISTRIBUTION_TYPE: "$DISTRIBUTION_TYPE"
84 }
85
86 set_variables_maven(){
87     echo "INFO: Setting maven variables"
88     if [[ -z ${VERSION:-} ]]; then
89         VERSION=$(yq -r ".version" "$release_file")
90     fi
91     if [[ -z ${GIT_TAG:-} ]]; then
92         if grep -q "git_tag" "$release_file" ; then
93             GIT_TAG=$(yq -r ".git_tag" "$release_file")
94         else
95             GIT_TAG="$VERSION"
96         fi
97     fi
98     if [[ -z ${LOG_DIR:-} ]]; then
99         LOG_DIR=$(yq -r ".log_dir" "$release_file")
100     fi
101     LOGS_URL="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
102     LOGS_URL=${LOGS_URL%/}  # strip any trailing '/'
103
104     # Continuing displaying Release Information (Maven)
105     printf "\t%-30s\n" RELEASE_MAVEN_INFO:
106     printf "\t%-30s %s\n" VERSION: "$VERSION"
107     printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
108     printf "\t%-30s %s\n" LOG_DIR: "$LOG_DIR"
109     printf "\t%-30s %s\n" LOGS_URL: "$LOGS_URL"
110 }
111
112 set_variables_container(){
113     echo "INFO: Setting container variables"
114     if [[ -z ${VERSION:-} ]]; then
115         VERSION=$(yq -r ".container_release_tag" "$release_file")
116     fi
117     if [[ -z ${GIT_TAG:-} ]]; then
118         if grep -q "git_tag" "$release_file" ; then
119             GIT_TAG=$(yq -r ".git_tag" "$release_file")
120         else
121             GIT_TAG="$VERSION"
122         fi
123    fi
124     if grep -q "container_pull_registry" "$release_file" ; then
125         CONTAINER_PULL_REGISTRY=$(yq -r ".container_pull_registry" "$release_file")
126     fi
127     if grep -q "container_push_registry" "$release_file" ; then
128         CONTAINER_PUSH_REGISTRY=$(yq -r ".container_push_registry" "$release_file")
129     fi
130     # Make sure both pull and push registries are defined
131     if [ -z ${CONTAINER_PULL_REGISTRY+x} ] || [ -z ${CONTAINER_PUSH_REGISTRY+x} ]; then
132         echo "ERROR: CONTAINER_PULL_REGISTRY and CONTAINER_PUSH_REGISTRY need to be defined"
133         exit 1
134     fi
135     ref=$(yq -r ".ref" "$release_file")
136
137     # Continuing displaying Release Information (Container)
138     printf "\t%-30s\n" RELEASE_CONTAINER_INFO:
139     printf "\t%-30s %s\n" CONTAINER_RELEASE_TAG: "$VERSION"
140     printf "\t%-30s %s\n" CONTAINER_PULL_REGISTRY: "$CONTAINER_PULL_REGISTRY"
141     printf "\t%-30s %s\n" CONTAINER_PUSH_REGISTRY: "$CONTAINER_PUSH_REGISTRY"
142     printf "\t%-30s %s\n" GERRIT_REF_TO_TAG: "$ref"
143     printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
144 }
145
146 set_variables_pypi(){
147     echo "INFO: Setting pypi variables"
148     if [[ -z ${LOG_DIR:-} ]]; then
149         LOG_DIR=$(yq -r ".log_dir" "$release_file")
150     fi
151     LOGS_URL="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
152     LOGS_URL=${LOGS_URL%/}  # strip any trailing '/'
153     if [[ -z ${PYPI_PROJECT:-} ]]; then
154         PYPI_PROJECT=$(yq -r ".pypi_project" "$release_file")
155     fi
156     if [[ -z ${PYTHON_VERSION:-} ]]; then
157         PYTHON_VERSION=$(yq -r ".python_version" "$release_file")
158     fi
159     if [[ -z ${VERSION:-} ]]; then
160         VERSION=$(yq -r ".version" "$release_file")
161     fi
162     if [[ -z ${GIT_TAG:-} ]]; then
163         if grep -q "git_tag" "$release_file" ; then
164             GIT_TAG=$(yq -r ".git_tag" "$release_file")
165         else
166             GIT_TAG="$VERSION"
167         fi
168    fi
169
170     # Continuing displaying Release Information (pypi)
171     printf "\t%-30s\n" RELEASE_PYPI_INFO:
172     printf "\t%-30s %s\n" LOG_DIR: "$LOG_DIR"
173     printf "\t%-30s %s\n" LOGS_URL: "$LOGS_URL"
174     printf "\t%-30s %s\n" PYPI_INDEX: "$PYPI_INDEX" # from job configuration
175     printf "\t%-30s %s\n" PYPI_PROJECT: "$PYPI_PROJECT"
176     printf "\t%-30s %s\n" PYTHON_VERSION: "$PYTHON_VERSION"
177     printf "\t%-30s %s\n" VERSION: "$VERSION"
178     printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
179 }
180
181 set_variables_packagecloud(){
182      echo "INFO: Setting packagecloud variables"
183      if [[ -z ${VERSION:-} ]]; then
184          VERSION=$(yq -r ".version" "$release_file")
185      fi
186      if [[ -z ${GIT_TAG:-} ]]; then
187          if grep -q "git_tag" $release_file ; then
188              GIT_TAG=$(yq -r ".git_tag" "$release_file")
189          else
190              GIT_TAG="$VERSION"
191          fi
192      fi
193      if [[ -z ${LOG_DIR:-} ]]; then
194          LOG_DIR=$(yq -r ".log_dir" "$release_file")
195      fi
196      if [[ -z ${REF:-} ]]; then
197          REF=$(yq -r ".ref" "$release_file")
198      fi
199      if [[ -z ${PACKAGE_NAME:-} ]]; then
200          PACKAGE_NAME=$(yq -r ".package_name" "$release_file")
201      fi
202      logs_url="${LOGS_SERVER}/${NEXUS_PATH}${LOG_DIR}"
203      logs_url=${logs_url%/}  # strip any trailing '/'
204
205      printf "\t%-30s %s\n" PACKAGE_NAME: "$PACKAGE_NAME"
206      printf "\t%-30s %s\n" LOG_DIR: "$LOG_DIR"
207      printf "\t%-30s %s\n" LOGS_URL: "$logs_url"
208      printf "\t%-30s %s\n" GERRIT_REF_TO_TAG: "$REF"
209      printf "\t%-30s %s\n" VERSION: "$VERSION"
210      printf "\t%-30s %s\n" GIT_TAG: "$GIT_TAG"
211 }
212
213 verify_schema(){
214     echo "INFO: Verifying $release_file against schema $release_schema"
215     lftools schema verify "$release_file" "$release_schema"
216 }
217
218 verify_version(){
219     # Verify allowed patterns "#.#.#" (SemVer) or "v#.#.#"
220     echo "INFO: Verifying version $VERSION"
221     allowed_version_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-]+)*)?$"
222     if [[ $VERSION =~ $allowed_version_regex ]]; then
223         echo "INFO: The version $VERSION is valid"
224     else
225         echo "ERROR: The version $VERSION is not valid"
226         echo "ERROR: Valid versions are \"#.#.#\" (SemVer) or \"v#.#.#\""
227         echo "ERROR: See https://semver.org/ for more details on SemVer"
228         exit 1
229     fi
230 }
231
232 verify_version_match_release(){
233     echo "INFO: Fetching console log from $LOGS_URL"
234     wget -P /tmp "${LOGS_URL}/"console.log.gz
235     echo "INFO: Searching for uploaded step and version $VERSION in job log"
236     if zgrep "Successfully uploaded" /tmp/console.log.gz | grep "$VERSION"; then
237         echo "INFO: found expected strings in job log"
238     else
239         echo "ERROR: Defined version in release file does not match staging repo artifacts version to be released"
240         echo "ERROR: Please make sure maven stage job log dir and release version are both correct"
241         exit 1
242     fi
243 }
244
245 # check prerequisites to detect mistakes in the release YAML file
246 verify_pypi_match_release(){
247     echo "INFO: Fetching console log from $LOGS_URL"
248     wget -q -P /tmp "${LOGS_URL}/"console.log.gz
249     echo "INFO: Searching for uploaded step, project $PYPI_PROJECT and version $VERSION in job log"
250     # pypi-upload.sh generates success message with file list
251     if zgrep -i "uploaded" /tmp/console.log.gz | grep "$PYPI_PROJECT" | grep "$VERSION" ; then
252         echo "INFO: found expected strings in job log"
253     else
254         echo "ERROR: failed to find expected strings in job log"
255         exit 1
256     fi
257 }
258
259 verify_packagecloud_match_release(){
260     echo "INFO: Fetching console log from $logs_url"
261     wget -q -P /tmp "${logs_url}/"console.log.gz
262     echo "INFO: Searching for uploaded step, package name $PACKAGE_NAME and version $VERSION in job log"
263     if  zgrep -E "Pushing.*$PACKAGE_NAME.*$VERSION.*success\!" /tmp/console.log.gz; then
264         echo "INFO: found expected strings in job log"
265     else
266         echo "ERROR: failed to find expected strings in job log"
267         exit 1
268     fi
269 }
270
271 # sigul is only available on Centos
272 # TODO: write tag-github-repo function
273 tag-gerrit-repo(){
274     if [[ $TAG_RELEASE == false ]]; then
275        echo "INFO: Skipping gerrit repo tag"
276        return
277     fi
278
279     echo "INFO: tag gerrit with $GIT_TAG"
280     # Import public signing key
281     gpg --import "$SIGNING_PUBKEY"
282     if type=$(git cat-file -t "$GIT_TAG"); then
283         if [[ $type == "tag" ]]; then
284             echo "INFO: Repo already has signed tag $GIT_TAG, nothing to do"
285         else
286             echo "ERROR: Repo has lightweight tag $GIT_TAG, blocks push of signed tag"
287             exit 1
288         fi
289     else
290         echo "INFO: Repo has not yet been tagged $GIT_TAG"
291         git tag -am "${PROJECT//\//-} $GIT_TAG" "$GIT_TAG"
292         sigul --batch -c "$SIGUL_CONFIG" sign-git-tag "$SIGUL_KEY" "$GIT_TAG" < "$SIGUL_PASSWORD"
293         echo "INFO: Showing latest signature for $PROJECT:"
294         echo "INFO: git tag -v $GIT_TAG"
295         git tag -v "$GIT_TAG"
296
297         ########## Merge Part ##############
298         if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
299             echo "INFO: Running merge, pushing tag"
300             gerrit_ssh=$(echo "$GERRIT_URL" | awk -F"/" '{print $3}')
301             git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/"$PROJECT"
302             git config user.name "$RELEASE_USERNAME"
303             git config user.email "$RELEASE_EMAIL"
304             echo -e "Host $gerrit_ssh\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
305             chmod 600 ~/.ssh/config
306             git push origin "$GIT_TAG"
307         fi
308     fi
309 }
310
311 nexus_release(){
312     echo "INFO: Processing nexus release"
313     for staging_url in $(zcat "$PATCH_DIR"/staging-repo.txt.gz | awk -e '{print $2}'); do
314         # extract the domain name from URL
315         NEXUS_URL=$(echo "$staging_url" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
316         echo "INFO: NEXUS_URL: $NEXUS_URL"
317         # extract the staging repo from URL
318         STAGING_REPO=${staging_url#*repositories/}
319         echo "INFO: Running Nexus Verify"
320         lftools nexus release -v --server https://"$NEXUS_URL" "$STAGING_REPO"
321         echo "INFO: Merge will run:"
322         echo "lftools nexus release --server https://$NEXUS_URL $STAGING_REPO"
323     done
324
325     #Run the loop twice, to catch errors on either nexus repo
326     if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
327         for staging_url in $(zcat "$PATCH_DIR"/staging-repo.txt.gz | awk -e '{print $2}'); do
328           NEXUS_URL=$(echo "$staging_url" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
329           STAGING_REPO=${staging_url#*repositories/}
330           echo "INFO: Promoting $STAGING_REPO on $NEXUS_URL."
331           lftools nexus release --server https://"$NEXUS_URL" "$STAGING_REPO"
332         done
333     fi
334 }
335
336 container_release_file(){
337     echo "INFO: Processing container release"
338     docker --version
339     local lfn_umbrella
340     lfn_umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')"
341
342     for namequoted in $(yq '.containers[].name' $release_file); do
343         versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" $release_file)
344
345         #Remove extra yaml quotes
346         name="${namequoted#\"}"
347         name="${name%\"}"
348         version="${versionquoted#\"}"
349         version="${version%\"}"
350
351         echo "$name"
352         echo "$version"
353         echo "INFO: Merge will release $name $version as $VERSION"
354         # Attempt to pull from releases registry to see if the image has been released.
355         if docker pull "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION"; then
356             echo "INFO: $VERSION is already released for image $name, Continuing..."
357         else
358             echo "INFO: $VERSION not found in releases, release will be prepared. Continuing..."
359             docker pull "$CONTAINER_PULL_REGISTRY"/"$lfn_umbrella"/"$name":"$version"
360             container_image_id=$(docker images | grep "$name" | grep "$version" | awk '{print $3}')
361             echo "INFO: Merge will run the following commands:"
362             echo "docker tag $container_image_id $CONTAINER_PUSH_REGISTRY/$lfn_umbrella/$name:$VERSION"
363             echo "docker push $CONTAINER_PUSH_REGISTRY/$lfn_umbrella/$name:$VERSION"
364             if [[ "$JOB_NAME" =~ "merge" ]]; then
365                 docker tag "$container_image_id" "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION"
366                 docker push "$CONTAINER_PUSH_REGISTRY"/"$lfn_umbrella"/"$name":"$VERSION"
367             fi
368             echo "#########################"
369         fi
370     done
371
372     echo "INFO: Merge will tag ref: $ref"
373     git checkout "$ref"
374     tag-gerrit-repo
375 }
376
377 maven_release_file(){
378     echo "INFO: Processing maven release"
379     echo "INFO: wget -P $PATCH_DIR ${LOGS_URL}/staging-repo.txt.gz"
380     wget -P "$PATCH_DIR" "${LOGS_URL}/"staging-repo.txt.gz
381     pushd "$PATCH_DIR"
382         echo "INFO: wget ${LOGS_URL}/patches/{${PROJECT//\//-}.bundle,taglist.log.gz}"
383         wget "${LOGS_URL}"/patches/{"${PROJECT//\//-}".bundle,taglist.log.gz}
384         gunzip taglist.log.gz
385         cat "$PATCH_DIR"/taglist.log
386     popd
387     git checkout "$(awk '{print $NF}' "$PATCH_DIR/taglist.log")"
388     git fetch "$PATCH_DIR/${PROJECT//\//-}.bundle"
389     git merge --ff-only FETCH_HEAD
390     nexus_release
391     tag-gerrit-repo
392 }
393
394 # calls pip to download binary and source distributions from the specified index,
395 # which requires a recent-in-2019 version.  Uploads the files it received.
396 pypi_release_file(){
397     echo "INFO: Processing pypi release"
398     tgtdir=dist
399     mkdir $tgtdir
400     pip_pfx="pip download -d $tgtdir --no-deps --python-version $PYTHON_VERSION -i $PYPI_INDEX"
401     module="$PYPI_PROJECT==$VERSION"
402     pip_bin="$pip_pfx $module"
403     echo "INFO: downloading binary: $pip_bin"
404     if ! $pip_bin ; then
405         echo "WARN: failed to download binary distribution"
406     fi
407     pip_src="$pip_pfx --no-binary=:all: $module"
408     echo "INFO: downloading source: $pip_src"
409     if ! $pip_src ; then
410         echo "WARN: failed to download source distribution"
411     fi
412     echo "INFO: Checking files in $tgtdir"
413     # shellcheck disable=SC2012
414     filecount=$(ls $tgtdir | wc -l)
415     if [[ $filecount = 0 ]] ; then
416         echo "ERROR: no files downloaded"
417         exit 1
418     else
419         # shellcheck disable=SC2046
420         echo "INFO: downloaded $filecount distributions: " $(ls $tgtdir)
421     fi
422
423     if [[ ! "$JOB_NAME" =~ "merge" ]] ; then
424         echo "INFO: not a merge job, not uploading files"
425         return
426     fi
427
428     cmd="twine upload -r $REPOSITORY $tgtdir/*"
429     if $DRY_RUN; then
430         echo "INFO: dry-run is set, echoing command only"
431         echo "$cmd"
432     else
433         echo "INFO: uploading $filecount distributions to repo $REPOSITORY"
434         $cmd
435     fi
436     tag-gerrit-repo
437 }
438
439 packagecloud_verify(){
440     echo "INFO: Verifying $1 exists in staging..."
441     if [[ $1 == $(curl --netrc-file ~/packagecloud_api --silent \
442         https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \
443         | yq -r .[].filename) ]]; then
444         echo "INFO: $1 exists in staging!"
445         echo "INFO: Existing package location: https://packagecloud.io$(curl \
446             --netrc-file ~/packagecloud_api --silent \
447             https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \
448             | yq -r .[].package_html_url)"
449     else
450         echo "ERROR: $1 does not exist in staging"
451         exit 1
452     fi
453 }
454
455 packagecloud_promote(){
456     echo "INFO: Preparing to promote $1..."
457     promote_url="https://packagecloud.io$(curl --netrc-file ~/packagecloud_api \
458         --silent https://packagecloud.io/api/v1/repos/"$2"/staging/search?q="$1" \
459         | yq -r .[].promote_url)"
460     echo "INFO: Promoting $1 from staging to release"
461     curl --netrc-file ~/packagecloud_api -X POST -F \
462         destination="$2/release" "$promote_url" \
463         | echo "INFO: Promoted package location: \
464         https://packagecloud.io$(yq -r .package_html_url)"
465     git checkout "$REF"
466     tag-gerrit-repo
467 }
468
469 ##############################  End Function Declarations  ################################
470
471 # Set common environment variables
472 set_variables_common
473
474 # Determine the type of release:
475 #   - container, release-container-schema.yaml
476 #   - maven, release-schema.yaml
477 #   - pypi,  release-pypi-schema.yaml
478
479 case $DISTRIBUTION_TYPE in
480
481     maven)
482         if $USE_RELEASE_FILE ; then
483             release_schema="release-schema.yaml"
484             echo "INFO: Fetching schema $release_schema"
485             wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/$release_schema
486             verify_schema
487         fi
488         set_variables_maven
489         verify_version
490         verify_version_match_release
491         maven_release_file
492         ;;
493
494     container)
495         if $USE_RELEASE_FILE ; then
496             release_schema="release-container-schema.yaml"
497             echo "INFO: Fetching schema $release_schema"
498             wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/${release_schema}
499             verify_schema
500         fi
501         set_variables_container
502         verify_version
503         container_release_file
504         ;;
505
506     pypi)
507         if $USE_RELEASE_FILE ; then
508             release_schema="release-pypi-schema.yaml"
509             echo "INFO: Fetching schema $release_schema"
510             wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/${release_schema}
511             verify_schema
512         fi
513         set_variables_pypi
514         verify_version
515         verify_pypi_match_release
516         pypi_release_file
517         ;;
518
519     packagecloud)
520         if $USE_RELEASE_FILE ; then
521             release_schema="release-packagecloud-schema.yaml"
522             packagecloud_account=$(cat "$ACCOUNT_NAME_FILE")
523             echo "INFO: Fetching schema $release_schema"
524             wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/${release_schema}
525             verify_schema
526         fi
527         set_variables_packagecloud
528         verify_packagecloud_match_release
529         for name in $(yq -r '.packages[].name' $release_file); do
530             package=$name
531             packagecloud_verify "$package" "$packagecloud_account"
532             if [[ "$JOB_NAME" =~ "merge" ]] && ! $DRY_RUN; then
533                 packagecloud_promote "$package" "$packagecloud_account"
534             fi
535         done
536         ;;
537
538     *)
539         echo "ERROR: distribution_type: $DISTRIBUTION_TYPE not supported"
540         exit 1
541         ;;
542 esac
543
544 echo "---> release-job.sh ends"