blob: beb94676fee5af55216cb004e1cf2b0a6f2fdcc3 [file] [log] [blame]
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -04001#!/bin/bash -l
2# SPDX-License-Identifier: EPL-1.0
3##############################################################################
Lott, Christopher (cl778h)fe4cf192020-03-26 21:26:14 -04004# Copyright (c) 2020 The Linux Foundation and others.
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -04005#
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)fe4cf192020-03-26 21:26:14 -040011
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)868ab362019-07-31 15:32:03 -040023echo "---> packagecloud-push.sh"
24set -eu -o pipefail
25
Lott, Christopher (cl778h)fe4cf192020-03-26 21:26:14 -040026# 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
29push_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)868ab362019-07-31 15:32:03 -040045 done
Lott, Christopher (cl778h)fe4cf192020-03-26 21:26:14 -040046}
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -040047
Lott, Christopher (cl778h)fe4cf192020-03-26 21:26:14 -040048echo "Working in directory $BUILD_DIR"
49cd "$BUILD_DIR"
50push_packages "*.deb" "$DEBIAN_DISTRIBUTION_VERSIONS"
51push_packages "*.rpm" "$RPM_DISTRIBUTION_VERSIONS"
52
53echo "---> packagecloud-push.sh ends"