-if [ ! -f ~/.packagecloud ]; then
- echo "INFO: .packagecloud file not found"
- exit 0
-fi
-
- # For DEB
-vers=("$DEBIAN_DISTRIBUTION_VERSIONS")
-echo "Debian distribution versions:" "${vers[@]}"
-debs=$(find . -type f -iname '*.deb')
-# modern bash syntax is helpful
-for (( i = 0; i < ${#vers[@]}; i++ )); do
- for deb in $debs; do
- echo "Pushing $deb $PACKAGECLOUD_ACCOUNT/$PACKAGECLOUD_REPO/${vers[i]}"
- package_cloud push "$PACKAGECLOUD_ACCOUNT"/"$PACKAGECLOUD_REPO"/"${vers[i]}" "$deb"
+# Pushes packages to PackageCloud
+# $1 is a shell-style glob pattern for package files
+# $2 is a space-separated list of distribution versions
+push_packages () {
+ echo "Expanding file pattern $1"
+ # shellcheck disable=SC2206
+ pkgs=($1)
+ if [[ ! -f ${pkgs[0]} ]]; then
+ echo "WARN: no files matched pattern $1"
+ return
+ fi
+ echo "Found package file(s):" "${pkgs[@]}"
+ echo "Processing distribution version(s): $2"
+ for ver in $2; do
+ arg="${PACKAGECLOUD_ACCOUNT}/${PACKAGECLOUD_REPO}/${ver}"
+ for pkg in "${pkgs[@]}"; do
+ echo "Pushing $arg $pkg"
+ package_cloud push "$arg" "$pkg"
+ done