aboutsummaryrefslogtreecommitdiff
path: root/start.sh
blob: 696f5afa20fbcd466e00b5fbb64c288d922c5425 (plain) (blame)
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
#!/bin/bash
root="$(pwd)"
build=/io
static=/static
srcdir=${root}/src
cache_left=${root}/cache
cache_right=/root/.cache

staging=staging
wheelhouse=wheelhouse
disthouse=disthouse

source "$(dirname ${BASH_SOURCE[0]})/etc/config.sh"
source "$(dirname ${BASH_SOURCE[0]})/etc/functions.sh"

export GREP_MODE='-G'
if [[ $(uname) == Linux ]]; then
    export GREP_MODE='-P'
elif [[ $(uname) == Darwin ]]; then
    export GREP_MODE='-E'
fi

for project in "${projects[@]}"
do
    url="${host}/${org}/${project}"
    dest="${srcdir}/${project}"

    if [[ ! -d ${dest} ]]; then
        msg "Retrieving source for: ${project}"
        git clone --recursive "${url}" "${dest}" &>/dev/null
        if [[ $? != 0 ]]; then
            msg2 "Failed to clone: ${url}"
            continue
        fi
    fi

    pushd "${dest}" &>/dev/null
        tags=$(git tag | grep ${GREP_MODE} ${tag_regex} | tail -n ${tag_limit})
        echo "Tags: ${tags}"

        for tag in $tags
        do
            git fetch --all &>/dev/null
            git reset --hard &>/dev/null
            git clean -ffxd &>/dev/null
            git checkout "${tag}" &>/dev/null

            msg "Initializing Docker image: ${docker_image}"
            docker run --rm -i -t \
                -v "${cache_left}:${cache_right}" \
                -v "${root}:${static}" \
                -v "${dest}:${build}" \
                "${docker_image}" ${static}/build-project.sh "${project}"
        done
    popd &>/dev/null
done

wheels_binary=$(find ${staging} -type f -name '*cp*-cp*m*.whl')
wheels_universal=$(find ${staging} -type f -name '*-any.whl')
dists=$(find ${staging} -type f -name '*.tar.gz')


mkdir -p ${wheelhouse}
mkdir -p ${disthouse}

if [[ $wheels_binary ]]; then
    msg2 "Exporting binary wheels..."
    for whl in $wheels_binary; do
        docker run --rm -i -t \
            -v "${root}:${static}" \
            "${docker_image}" \
            auditwheel repair \
                "${static}/${whl}" \
                -w ${static}/wheelhouse
        if [[ $? == 0 ]]; then
            rm -f "${whl}"
        fi
    done
fi

set +e

# "auditwheel" wastes time for univeral wheels
if [[ $wheels_universal ]]; then
    msg2 "Exporting universal wheels..."
    for whl in $wheels_universal; do
        msg3 "$(basename ${whl})"
        mv "${whl}" "${wheelhouse}"
    done
fi

if [[ $dists ]]; then
    msg2 "Exporting source dists..."
    for dist in ${dists}; do
        msg3 "$(basename "${dist}")"
        mv "${dist}" "${disthouse}"
    done
fi