Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 1 | #!/bin/bash -l |
| 2 | # SPDX-License-Identifier: EPL-1.0 |
| 3 | ############################################################################## |
Lott, Christopher (cl778h) | fe4cf19 | 2020-03-26 21:26:14 -0400 | [diff] [blame] | 4 | # Copyright (c) 2020 The Linux Foundation and others. |
Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 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 | ############################################################################## |
Lott, Christopher (cl778h) | fe4cf19 | 2020-03-26 21:26:14 -0400 | [diff] [blame] | 11 | |
| 12 | # Prereqs: |
| 13 | # The build minion has the ruby gem "package_cloud" |
| 14 | # The required credentials and API files have been provisioned |
| 15 | # The build directory has .deb/.rpm files |
| 16 | # Environment variables: |
| 17 | # BUILD_DIR is set and non-empty |
| 18 | # DEBIAN_DISTRIBUTION_VERSIONS has distro list like "debian/stretch" |
| 19 | # RPM_DISTRIBUTION_VERSIONS has distro list like "el/4 el/5" |
| 20 | # PACKAGECLOUD_ACCOUNT is set and non-empty |
| 21 | # PACKAGECLOUD_REPO is a value like "staging" |
| 22 | |
Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 23 | echo "---> packagecloud-push.sh" |
| 24 | set -eu -o pipefail |
| 25 | |
Lott, Christopher (cl778h) | fe4cf19 | 2020-03-26 21:26:14 -0400 | [diff] [blame] | 26 | # Pushes packages to PackageCloud |
| 27 | # $1 is a shell-style glob pattern for package files |
| 28 | # $2 is a space-separated list of distribution versions |
| 29 | push_packages () { |
| 30 | echo "Expanding file pattern $1" |
| 31 | # shellcheck disable=SC2206 |
| 32 | pkgs=($1) |
| 33 | if [[ ! -f ${pkgs[0]} ]]; then |
| 34 | echo "WARN: no files matched pattern $1" |
| 35 | return |
| 36 | fi |
| 37 | echo "Found package file(s):" "${pkgs[@]}" |
| 38 | echo "Processing distribution version(s): $2" |
| 39 | for ver in $2; do |
| 40 | arg="${PACKAGECLOUD_ACCOUNT}/${PACKAGECLOUD_REPO}/${ver}" |
| 41 | for pkg in "${pkgs[@]}"; do |
| 42 | echo "Pushing $arg $pkg" |
| 43 | package_cloud push "$arg" "$pkg" |
| 44 | done |
Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 45 | done |
Lott, Christopher (cl778h) | fe4cf19 | 2020-03-26 21:26:14 -0400 | [diff] [blame] | 46 | } |
Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 47 | |
Lott, Christopher (cl778h) | fe4cf19 | 2020-03-26 21:26:14 -0400 | [diff] [blame] | 48 | echo "Working in directory $BUILD_DIR" |
| 49 | cd "$BUILD_DIR" |
| 50 | push_packages "*.deb" "$DEBIAN_DISTRIBUTION_VERSIONS" |
| 51 | push_packages "*.rpm" "$RPM_DISTRIBUTION_VERSIONS" |
| 52 | |
| 53 | echo "---> packagecloud-push.sh ends" |