-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sh
executable file
·80 lines (65 loc) · 2.93 KB
/
build.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
#!/bin/bash
DOCKER_TAG="haproxytech/haproxy-debian"
HAPROXY_GITHUB_URL="https://github.com/haproxytech/haproxy-docker-debian/blob/main"
HAPROXY_BRANCHES="2.2 2.4 2.6 2.8 2.9 3.0 3.1"
HAPROXY_CURRENT_BRANCH="3.0"
PUSH="no"
HAPROXY_UPDATED=""
for i in $HAPROXY_BRANCHES; do
echo "Building HAProxy $i"
DOCKERFILE="$i/Dockerfile"
HAPROXY_MINOR_OLD=$(awk '/^ENV HAPROXY_MINOR/ {print $NF}' "$DOCKERFILE")
DATAPLANE_MINOR_OLD=$(awk '/^ENV DATAPLANE_MINOR/ {print $NF}' "$DOCKERFILE")
./update.sh "$i" || continue
HAPROXY_MINOR=$(awk '/^ENV HAPROXY_MINOR/ {print $NF}' "$DOCKERFILE")
DATAPLANE_MINOR=$(awk '/^ENV DATAPLANE_MINOR/ {print $NF}' "$DOCKERFILE")
if [ "x$1" != "xforce" ]; then
if [ \( "$HAPROXY_MINOR_OLD" = "$HAPROXY_MINOR" \) -a \( "$DATAPLANE_MINOR_OLD" = "$DATAPLANE_MINOR" \) ]; then
echo "No new releases, not building $i branch"
continue
fi
fi
PUSH="yes"
HAPROXY_UPDATED="$HAPROXY_UPDATED $HAPROXY_MINOR"
if [ \( "x$1" = "xtest" \) -o \( "x$2" = "xtest" \) ]; then
docker pull $(awk '/^FROM/ {print $2}' "$DOCKERFILE")
docker build -t "$DOCKER_TAG:$HAPROXY_MINOR" "$i" || \
(echo "Failure building $DOCKER_TAG:$HAPROXY_MINOR"; exit 1)
docker tag "$DOCKER_TAG:$HAPROXY_MINOR" "$DOCKER_TAG:$i"
if [ "$i" = "$HAPROXY_CURRENT_BRANCH" ]; then
docker tag "$DOCKER_TAG:$HAPROXY_MINOR" "$DOCKER_TAG:latest"
fi
docker run -it --rm "$DOCKER_TAG:$HAPROXY_MINOR" /usr/local/sbin/haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg || \
(echo "Failure testing $DOCKER_TAG:$HAPROXY_MINOR"; exit 1)
fi
git tag -d "$HAPROXY_MINOR" || true
git push origin ":$HAPROXY_MINOR" || true
git commit -a -m "Automated commit triggered by $HAPROXY_MINOR release(s)" || true
git tag "$HAPROXY_MINOR"
git push origin "$HAPROXY_MINOR"
done
if [ "$PUSH" = "no" ]; then
exit 0
fi
echo -e "# Supported tags and respective \`Dockerfile\` links\n" > README.md
for i in $(awk '/^ENV HAPROXY_MINOR/ {print $NF}' */Dockerfile| sort -n -r); do
short=$(echo $i | cut -d. -f1-2 |cut -d- -f1)
if [ "$short" = "$HAPROXY_CURRENT_BRANCH" ]; then
if [ "$short" = "$i" ]; then
final="-\t[\`$i\`, \`latest\`]($HAPROXY_GITHUB_URL/$short/Dockerfile)"
else
final="-\t[\`$i\`, \`$short\`, \`latest\`]($HAPROXY_GITHUB_URL/$short/Dockerfile)"
fi
else
if [ "$short" = "$i" ]; then
final="-\t[\`$i\`]($HAPROXY_GITHUB_URL/$short/Dockerfile)"
else
final="-\t[\`$i\`, \`$short\`]($HAPROXY_GITHUB_URL/$short/Dockerfile)"
fi
fi
echo -e "$final" >> README.md
done
echo >> README.md
cat README_short.md >> README.md
git commit -a -m "README regen triggered by $HAPROXY_UPDATED release(s)" || true
git push