Define Docker-CI-PC merge job template
[ci-management.git] / jjb / oran-jjb / shell / packagecloud-push.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 "---> packagecloud-push.sh"
12 set -eu -o pipefail
13
14 if [ ! -f ~/.packagecloud ]; then
15     echo "INFO: .packagecloud file not found"
16     exit 0
17 fi
18
19  # For DEB
20 vers=("$DEBIAN_DISTRIBUTION_VERSIONS")
21 echo "Debian distribution versions:" "${vers[@]}"
22 debs=$(find . -type f -iname '*.deb')
23 # modern bash syntax is helpful
24 for (( i = 0; i < ${#vers[@]}; i++ )); do
25     for deb in $debs; do
26        echo "Pushing $deb $PACKAGECLOUD_ACCOUNT/$PACKAGECLOUD_REPO/${vers[i]}"
27        package_cloud push "$PACKAGECLOUD_ACCOUNT"/"$PACKAGECLOUD_REPO"/"${vers[i]}" "$deb"
28     done
29 done
30
31 # For RPM
32 vers=("$RPM_DISTRIBUTION_VERSIONS")
33 echo "RPM distribution versions:" "${vers[@]}"
34 rpms=$(find . -type f -iregex '.*/.*\.\(s\)?rpm')
35 # modern bash syntax is helpful
36 for (( i = 0; i < ${#vers[@]}; i++ )); do
37     for rpm in $rpms; do
38        echo "Pushing $rpm $PACKAGECLOUD_ACCOUNT/$PACKAGECLOUD_REPO/${vers[i]}"
39        package_cloud push "$PACKAGECLOUD_ACCOUNT"/"$PACKAGECLOUD_REPO"/"${vers[i]}" "$rpm"
40     done
41 done