-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorchestrator
executable file
·105 lines (89 loc) · 2.17 KB
/
orchestrator
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
#!/usr/bin/env bash
# vim: ft=sh tw=80
declare help="
Orchestrator script for Deb-building development images.
Usage:
orchestrator test
orchestrator push
orchestrator build
orchestrator update-versions
orchestrator --version
orchestrator -h | --help
Options:
-h --help Show this screen.
--version Show versions.
"
declare version="
Version: 1.0.0.
Licensed under the MIT terms.
"
declare ARCH
ARCH="$(uname -m)"
declare VERSIONS="${VERSIONS:-versions/$ARCH/*}"
build() {
declare build_files="${*:-$VERSIONS}"
echo "Building for architecture: $ARCH"
echo "Will build versions: $build_files"
for version in $build_files; do
echo "Building version $version"
( # shellcheck source=versions/x86_64/debian-unstable/options
source "$version"/options
for tag in "${TAGS[@]}"; do
docker build --pull -t "$tag" "$version"
done
)
done
}
run_tests() {
echo "Tests running for $ARCH:"
declare -a test_files
for file in $VERSIONS; do
source "$file/options"
local tag
tag="${TAGS[0]}"
tag="${tag//:/-}"
tag="${tag//\//_}"
test_files+=("tests/test_${tag}.bats")
done
bats "${test_files[@]}"
}
push() {
[[ "$NO_PUSH" ]] && return 0
declare push_files="${*:-$VERSIONS}"
echo "Pushing for architecture: $ARCH"
echo "Will push versions $push_files"
for version in $push_files; do
echo "Pushing version $version"
( # shellcheck source=versions/x86_64/debian-unstable/options
source "$version"/options
for tag in "${TAGS[@]}"; do
if docker history "$tag" &> /dev/null; then
docker push "$tag"
fi
done
)
done
}
update_versions() {
bash bin/update-versions.sh run
}
version() {
echo "$version"
}
help() {
echo "$help"
}
main() {
set -eo pipefail; [[ "$TRACE" ]] && set -x
declare cmd="$1"
case "$cmd" in
test) shift; run_tests "$@";;
build) shift; build "$@";;
push) shift; push "$@";;
update-versions) shift; update_versions;;
-h|--help) shift; help "$@";;
--version) shift; version;;
*) help "$@";;
esac
}
main "$@"