-
Notifications
You must be signed in to change notification settings - Fork 5
/
.packagecloud-publish.sh
executable file
·107 lines (85 loc) · 2.53 KB
/
.packagecloud-publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# This script publishes ".deb" and ".rpm" files in the ./dist
# dir to packagecloud. This script relies on the existence
# of the "packagecloud" binary: https://github.com/edgeworx/packagecloud
# The binary can be installed via: go install github.com/edgeworx/packagecloud@v0.1.0
set -e
echo ""
echo "*************** Publish to packagecloud.io ***************"
if [[ -z "$PACKAGECLOUD_TOKEN" ]]; then
echo "Must provide PACKAGECLOUD_TOKEN envar" 1>&2
exit 1
fi
repo="${PACKAGECLOUD_REPO:-iofog/iofogctl-snapshots}"
echo "Using packagecloud repo: $repo"
pushd ./dist > /dev/null
echo "Using dist dir: $PWD"
failed_push_file='./failed_packagecloud_push'
echo -n "" > $failed_push_file
# add some stutter to avoid overloading packagecloud API
function sleepStutter() {
sleep "0.$((50 + RANDOM % 300))s"
}
function deb() {
packages=$(ls | grep .deb)
echo ""
echo "*************** Publish .deb ***************"
echo "deb packages to publish..."
echo "$packages"
echo ""
declare -a distro_versions=(
"ubuntu/focal" "ubuntu/xenial" "ubuntu/bionic" "ubuntu/trusty" "ubuntu/jammy"
"debian/stretch" "debian/buster" "debian/bullseye"
"raspbian/stretch" "raspbian/buster" "raspbian/bullseye"
"any/any"
)
for package in $packages; do
for distro_version in "${distro_versions[@]}"; do
sleepStutter
repo_full_path="$repo/$distro_version"
echo $repo_full_path
{
packagecloud push --overwrite "${repo_full_path}" "${package}" 2> >(tee -a $failed_push_file >&2)
} &
done
done
wait
}
function rpm() {
packages=$(ls | grep .rpm)
echo ""
echo "*************** Publish .rpm ***************"
echo "rpm packages to publish..."
echo "$packages"
echo ""
declare -a distro_versions=(
"fedora/23" "fedora/24" "fedora/30" "fedora/31"
"el/6" "el/7" "el/8"
"rpm_any/rpm_any"
)
for package in $packages; do
for distro_version in "${distro_versions[@]}"; do
sleepStutter
repo_full_path="$repo/$distro_version"
{
packagecloud push --overwrite "${repo_full_path}" "${package}" 2> >(tee -a $failed_push_file >&2)
} &
done
done
wait
}
deb &
sleep 0.1s # give the deb func time to do its output
rpm &
wait
echo ""
if [ -s $failed_push_file ]; then
# There's content in #failed_push_file... so we need to output it and exit 1.
echo "*************** Failures (from $failed_push_file) ***************"
echo ""
cat $failed_push_file
echo ""
exit 1
else
echo "*************** SUCCESS ***************"
fi