forked from docker-library/ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·63 lines (54 loc) · 1.37 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
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
allVersions="$(
git ls-remote --tags https://github.com/TryGhost/Ghost.git \
| cut -d$'\t' -f2 \
| grep -E '^refs/tags/[0-9]+\.[0-9]+' \
| cut -d/ -f3 \
| sort -rV
)"
cliVersion="$(
git ls-remote --tags https://github.com/TryGhost/Ghost-CLI.git \
| cut -d$'\t' -f2 \
| grep -E '^refs/tags/[0-9]+\.[0-9]+' \
| cut -d/ -f3 \
| sort -rV \
| head -n1
)"
travisEnv=
for version in "${versions[@]}"; do
rcVersion="${version%-rc}"
rcGrepV='-v'
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
rcGrepV+=' -E'
rcGrepExpr='alpha|beta|rc'
fullVersion="$(
echo "$allVersions" \
| grep -E "^${rcVersion}([.-]|$)" \
| grep $rcGrepV -- "$rcGrepExpr" \
| head -1
)"
if [ -z "$fullVersion" ]; then
echo >&2 "error: cannot determine full version for '$version'"
fi
(
set -x
sed -ri \
-e 's/^(ENV GHOST_VERSION) .*/\1 '"$fullVersion"'/' \
-e 's/^(ENV GHOST_CLI_VERSION) .*/\1 '"$cliVersion"'/' \
"$version"/*/Dockerfile
)
for variant in alpine debian; do
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