-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish.sh
executable file
·79 lines (60 loc) · 1.91 KB
/
publish.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
77
78
79
#!/bin/bash
set -e
scriptDir=$(cd "$(dirname $0)" && echo "$(pwd -P)")
clientImage=uncaught42/doko-stats-client
databaseImage=uncaught42/doko-stats-db
serverImage=uncaught42/doko-stats-server
cd $scriptDir
source $scriptDir/.env
if [ -f .env.local ]; then
source $scriptDir/.env.local
fi
vers=${1:-0.0.0}
color() { echo -e "\033[0;$1m$2\033[0m"; }
step() { color 95 "$1"; }
success() { color 32 "$1"; }
warn() { color 33 "$1"; }
error() { color 31 "$1"; }
if [ "$vers" = "0.0.0" ]; then
warn "Version $vers used - not creating git tag"
elif [[ $vers =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then
success "Version $vers accepted! Creating git tag ..."
git tag -a v$vers -m "Create tag for version $vers"
git push --follow-tags
else
error "Version $vers is not of a valid format!"
exit 1
fi
echo ""
step "Building client ..."
cd $scriptDir/packages/client
docker build --pull -f Dockerfile --build-arg vers=$vers -t $clientImage:$vers -t $clientImage:latest ..
echo ""
step "Building database ..."
cd $scriptDir/packages/database
docker build --pull -f Dockerfile -t $databaseImage:$vers -t $databaseImage:latest .
echo ""
step "Building server ..."
cd $scriptDir/packages/server
docker build --pull -f Dockerfile -t $serverImage:$vers -t $serverImage:latest ..
cd $scriptDir
echo ""
if [ "$vers" = "0.0.0" ]; then
warn "Not pushing images to docker hub due to local version"
else
step "Pushing images ..."
if [ "$DOCKER_LOGIN_USER" != "" ] && [ "$DOCKER_LOGIN_TOKEN" != "" ]; then
echo "$DOCKER_LOGIN_TOKEN" | docker login -u $DOCKER_LOGIN_USER --password-stdin
fi
docker push -q $clientImage:$vers
docker push -q $clientImage:latest
docker push -q $databaseImage:$vers
docker push -q $databaseImage:latest
docker push -q $serverImage:$vers
docker push -q $serverImage:latest
if [ "$DOCKER_LOGIN_USER" != "" ] && [ "$DOCKER_LOGIN_TOKEN" != "" ]; then
docker logout
fi
fi
echo ""
success "Build complete!"