-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sh
executable file
·52 lines (39 loc) · 1.35 KB
/
build.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
#!/bin/bash
# This can be used to build the HaikuDepotServer. It should be
# run from the top level of the HDS project.
git diff-index --quiet HEAD
if [[ $? != 0 ]]; then
echo "! it seems that there are uncommitted changes - commit the changes before proceeding"
exit 1
fi
HDS_TAG="$(git describe --tags)"
HDS_TAG_REGEX='^haikudepotserver-([0-9]+\.[0-9]+\.[0-9]+)$'
if [[ $HDS_TAG =~ $HDS_TAG_REGEX ]]; then
HDS_VERSION="${BASH_REMATCH[1]}"
else
echo "! tag \"${HDS_TAG}\" would indicate the repo is not on a tag"
exit 1
fi
TOP_POM_VERSION="$(sed -n -e "s/\s*<version>\(..*\)<\/version>\s*/\1/p" pom.xml)"
if [[ ${TOP_POM_VERSION} != ${HDS_VERSION} ]]; then
echo "! the top-level pom version [${TOP_POM_VERSION}] is not the same as the tag version [${HDS_VERSION}]"
exit 1
fi
read -r -p "Press 'y' to docker build HaikuDepotServer ${HDS_VERSION}: " choice
if ! [[ "$choice" = 'y' ]]; then
exit 1
fi
docker build --tag "ghcr.io/haiku/haikudepotserver:${HDS_VERSION}" .
if [[ $? != 0 ]]; then
echo "failed to create docker image for HaikuDepotServer"
exit 1
fi
read -r -p "Press 'y' to push the docker image HaikuDepotServer ${HDS_VERSION}: " choice
if ! [[ "$choice" = 'y' ]]; then
exit 1
fi
docker push "ghcr.io/haiku/haikudepotserver:${HDS_VERSION}"
if [[ $? != 0 ]]; then
echo "failed to push the docker image for HaikuDepotServer"
exit 1
fi