forked from docker-library/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·76 lines (66 loc) · 2.14 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
69
70
71
72
73
74
75
76
#!/bin/bash
set -eo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( */ )
versions=( "${versions[@]%/}" )
tags="$(git ls-remote --tags https://github.com/elastic/kibana.git | cut -d/ -f3 | cut -d^ -f1 | cut -dv -f2 | sort -rV)"
debArch="$(dpkg --print-architecture)"
travisEnv=
for version in "${versions[@]}"; do
# major.minor.patch
versionMajor="${version%%.*}"
versionMinor="${version#$versionMajor.}"
[ "$versionMinor" != "$version" ] || versionMinor=
versionMinor="${versionMinor%%.*}"
fullVersion=
sha1=
if (
[ "$versionMajor" -eq 4 ] \
&& [ -n "$versionMinor" ] \
&& [ "$versionMinor" -ge 4 ] \
) || [ "$versionMajor" -gt 4 ]; then
if [ "$versionMajor" -eq 5 ]; then
repoBase='https://artifacts.elastic.co/packages/5.x/apt'
else
repoBase="http://packages.elastic.co/kibana/$version/debian"
fi
packagesUri="$repoBase/dists/stable/main/binary-$debArch/Packages"
debVersions="$(
curl -fsSL "$packagesUri" \
| awk -F ': +' '
$1 == "Package" { pkg = $2 }
pkg == "kibana" && $1 == "Version" { print $2 }
' \
| sort -rV
)"
fullVersion="$(echo "$debVersions" | head -n1)"
else
possibleVersions="$(echo "$tags" | grep "^$version\.")"
nonBetaVersions="$(echo "$possibleVersions" | grep -vE 'milestone|-beta|-m')"
# prefer full releases over beta or milestone
if [ "$nonBetaVersions" ]; then
fullVersion="$(echo "$nonBetaVersions" | head -n1)"
else
fullVersion="$(echo "$possibleVersions" | head -n1)"
fi
sha1="$(curl -fsSL "https://download.elastic.co/kibana/kibana/kibana-$fullVersion-linux-x64.tar.gz.sha1.txt" | cut -d' ' -f1)"
fi
if [ -z "$fullVersion" ]; then
echo >&2
echo >&2 "warning: unable to figure out 'full version' for $version"
echo >&2 ' skipping'
echo >&2
continue
fi
(
set -x
sed -ri '
s/^(ENV KIBANA_MAJOR) .*/\1 '"$version"'/;
s/^(ENV KIBANA_VERSION) .*/\1 '"$fullVersion"'/;
s/^(ENV KIBANA_SHA1) .*/\1 '"$sha1"'/;
' "$version/Dockerfile"
)
travisEnv='\n - VERSION='"$version$travisEnv"
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml