-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathupdate.sh
executable file
·51 lines (43 loc) · 1.3 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
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
allVersions="$(
git ls-remote --tags https://github.com/vrana/adminer.git \
| cut -d$'\t' -f2 \
| grep -E '^refs/tags/v[0-9]+\.[0-9]+' \
| cut -dv -f2 \
| sort -rV
)"
for version in "${versions[@]}"; do
fullVersion="$(
grep -E "^${version}([.-]|$)" <<<"$allVersions" \
| head -1
)"
if [ -z "$fullVersion" ]; then
echo >&2 "error: cannot determine full version for '$version'"
fi
echo "$version: $fullVersion"
downloadSha256="$(
curl -fsSL "https://github.com/vrana/adminer/releases/download/v${fullVersion}/adminer-${fullVersion}.php" \
| sha256sum \
| cut -d' ' -f1
)"
echo " - adminer-${fullVersion}.php: $downloadSha256"
srcDownloadSha256="$(
curl -fsSL "https://github.com/vrana/adminer/archive/v${fullVersion}.tar.gz" \
| sha256sum \
| cut -d' ' -f1
)"
echo " - v${fullVersion}.tar.gz: $srcDownloadSha256"
sed -ri \
-e 's/^(ENV\s+ADMINER_VERSION=).*/\1'"$fullVersion"'/' \
-e 's/^(ENV\s+ADMINER_DOWNLOAD_SHA256=).*/\1'"$downloadSha256"'/' \
-e 's/^(ENV\s+ADMINER_SRC_DOWNLOAD_SHA256=).*/\1'"$srcDownloadSha256"'/' \
"$version/fastcgi/Dockerfile" \
"$version/Dockerfile"
done