update Docker build script to be usable for all branches

This commit is contained in:
Ralf Becker 2019-08-09 18:31:43 +02:00
parent 97953fab45
commit 011a8d5a03

View File

@ -1,15 +1,18 @@
#!/bin/bash -x
TAG=${1:-dev-master}
DEFAULT=$(git branch|grep ^*|cut -c3-)
TAG=${1:-$DEFAULT}
VERSION=$TAG
BRANCH=$(echo $VERSION|sed 's/\.[0-9]\{8\}$//')
[ $VERSION = $BRANCH ] && VERSION="$BRANCH.x-dev"
[ $VERSION = "dev-master" ] && {
cd ~/egroupware
[ $VERSION = "$DEFAULT.x-dev" ] && {
cd $(dirname $0)
grep self.version composer.json | while read pack version; do composer update $(echo $pack|cut -d'"' -f2); done
git status composer.lock|grep composer.lock && {
git stash; git pull --rebase; git stash pop
git commit -m 'updating composer.lock with latest commit hashed for egroupware/* packages' composer.lock
VERSION="$VERSION#$(git push|grep master|cut -c4-10)"
VERSION="$VERSION#$(git push|grep $DEFAULT|cut -c4-10)"
}
}
@ -19,18 +22,12 @@ docker pull ubuntu:18.04
docker build --no-cache --build-arg "VERSION=$VERSION" -t egroupware/egroupware:$TAG . && {
docker push egroupware/egroupware:$TAG
# tag only stable releases as latest
[ $TAG != "dev-master" ] && \
{
[ $TAG != "master" ] && {
docker tag egroupware/egroupware:$TAG egroupware/egroupware:latest
docker push egroupware/egroupware:latest
}
BRANCH=$(echo $VERSION|sed 's/\.[0-9]\{8\}$//')
[ "$BRANCH" != $VERSION -a "dev-$BRANCH" != $VERSION ] && {
[ "$BRANCH" != $VERSION -a "${BRANCH}.x-dev" != $VERSION ] && {
docker tag egroupware/egroupware:$VERSION egroupware/egroupware:$BRANCH
docker push egroupware/egroupware:$BRANCH
}
[ $VERSION != "dev-master" ] && {
docker tag egroupware/egroupware:$VERSION egroupware/egroupware:latest
docker push egroupware/egroupware:latest
}
}