forked from docker-library/rabbitmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·68 lines (58 loc) · 1.82 KB
/
update.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
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
travisEnv=
for version in "${versions[@]}"; do
rcVersion="${version%-rc}"
rcGrepV='-v'
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
rcGrepV+=' -E'
rcGrepExpr='beta|milestone|rc'
githubTag="$(
git ls-remote --tags https://github.com/rabbitmq/rabbitmq-server.git \
"refs/tags/rabbitmq_v${rcVersion//./_}_*" \
"refs/tags/v${rcVersion}.*" \
| cut -d'/' -f3- \
| grep $rcGrepV -- "$rcGrepExpr" \
| sort -V \
| tail -1
)"
githubReleaseUrl="https://github.com/rabbitmq/rabbitmq-server/releases/tag/$githubTag"
fullVersion="$(
curl -fsSL "$githubReleaseUrl" \
| grep -o "/rabbitmq-server-generic-unix-${rcVersion}[.].*[.]tar[.]xz" \
| head -1 \
| sed -r "s/^.*(${rcVersion}.*)[.]tar[.]xz/\1/"
)"
debianVersion="$(
curl -fsSL "$githubReleaseUrl" \
| grep -o "/rabbitmq-server_${rcVersion}[.].*_all[.]deb" \
| head -1 \
| sed -r "s/^.*(${rcVersion}.*)_all[.]deb/\1/"
)"
if [ -z "$fullVersion" ] || [ -z "$debianVersion" ]; then
echo >&2 "warning: failed to get full ('$fullVersion') or Debian ('$debianVersion') version for '$version'; skipping"
continue
fi
for variant in alpine debian; do
[ -f "$version/$variant/Dockerfile" ] || continue
(
set -x
sed -ri \
-e 's/^(ENV RABBITMQ_VERSION) .*/\1 '"$fullVersion"'/' \
-e 's/^(ENV RABBITMQ_GITHUB_TAG) .*/\1 '"$githubTag"'/' \
-e 's/^(ENV RABBITMQ_DEBIAN_VERSION) .*/\1 '"$debianVersion"'/' \
"$version/$variant/Dockerfile"
)
travisEnv='\n - VERSION='"$version"' VARIANT='"$variant$travisEnv"
done
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml