-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
64 lines (48 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
#!/bin/bash
set -eo pipefail
# version_greater_or_equal A B returns whether A >= B
function version_greater_or_equal() {
[[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" || "$1" == "$2" ]];
}
dockerRepo="monogramm/docker-axelor-development-kit"
# TODO Find a way to retrieve automatically the latest versions from GitHub
# latests=( $( curl -fsSL 'https://api.github.com/repos/axelor/axelor-development-kit/tags' |tac|tac| \
# grep -oE '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | \
# sort -urV ) )
latests=( "4.1.8" "5.0.11" )
# FIXME Remove versions prior to 4.0 due to following error:
# Could not find org.apache.directory.jdbm:apacheds-jdbm1:2.0.0-M3-SNAPSHOT.
# Required by: com.axelor:axelor-core:3.4.2
# Remove existing images
echo "reset docker images"
find ./images -maxdepth 1 -type d -regextype sed -regex '\./images/[[:digit:]]\+\.[[:digit:]]\+' -exec rm -r '{}' \;
echo "update docker images"
travisEnv=
for latest in "${latests[@]}"; do
version=$(echo "$latest" | cut -d. -f1-2)
if [ -d "$version" ]; then
continue
fi
# Only add versions >= 4.0
if version_greater_or_equal "$version" "4.0"; then
echo "updating $latest [$version]"
# Create the version directory with a Dockerfile.
dir="images/$version"
mkdir -p "$dir"
template="Dockerfile.alpine.template"
cp "$template" "$dir/Dockerfile"
# Replace the variables.
sed -ri -e '
s/%%ADK_VERSION%%/'"$latest"'/g;
' "$dir/Dockerfile"
travisEnv='\n - VERSION='"$version$travisEnv"
if [[ $1 == 'build' ]]; then
tag="$version"
echo "Build Dockerfile for ${tag}"
docker build -t ${dockerRepo}:${tag} $dir
fi
fi
done
# update .travis.yml
travis="$(awk -v 'RS=\n\n' '$1 == "env:" && $2 == "#" && $3 == "Environments" { $0 = "env: # Environments'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml