summaryrefslogtreecommitdiffstats
path: root/.github/scripts/package-upload.sh
blob: 9305ffa6712d478639b2740a6b7d4af06112fd87 (plain)
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
#!/bin/sh

set -e

user="netdatabot"

host="${1}"
distro="${2}"
arch="${3}"
format="${4}"
repo="${5}"
pkg_src="${6:-./artifacts}"

staging="${TMPDIR:-/tmp}/package-staging"
prefix="/home/netdatabot/incoming/${repo}/"

packages="$(find "${pkg_src}" -name "*.${format}")"

mkdir -p "${staging}"

case "${format}" in
    deb)
        src="${staging}/${distro}"
        mkdir -p "${src}"

        for pkg in ${packages}; do
            cp "${pkg}" "${src}"
        done
        ;;
    rpm)
        src="${staging}/${distro}/${arch}/"
        mkdir -p "${src}"

        for pkg in ${packages}; do
            cp "${pkg}" "${src}"
        done
        ;;
    *)
        echo "Unrecognized package format ${format}."
        exit 1
        ;;
esac

rsync -vrptO "${staging}/" "${user}@${host}:${prefix}"