-
Notifications
You must be signed in to change notification settings - Fork 529
/
build-release.sh
executable file
·49 lines (42 loc) · 1.27 KB
/
build-release.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
#!/bin/sh
set -e
branch=`git rev-parse --abbrev-ref HEAD`
if [ "$branch" = "master" ]; then
set +e # ignore error of following command
tag=`git describe --exact-match --tags HEAD`
exit_code=$?
set -e
if [ $exit_code = 0 ]; then
image_tag=`git describe --tags`
else
image_tag="latest"
fi
else
image_tag=$branch
fi
version=`git describe --tags`
echo "Branch: $branch"
echo "Tag: $tag"
echo "Image tag: $image_tag"
echo "Version: $version"
mkdir -p tmp
# build jar
docker run -e http_proxy=$http_proxy -v `pwd`:/mnt/build --entrypoint=/bin/sh maven:3-jdk-8 -c "\
curl -sL https://deb.nodesource.com/setup_7.x | bash - \
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
&& ln -sf /usr/bin/nodejs /usr/bin/node \
&& cp -r /mnt/build /chronos \
&& cd /chronos \
&& mvn clean \
&& mvn versions:set -DnewVersion=$version \
&& mvn package \
&& cp target/chronos-$version.jar /mnt/build/tmp/chronos.jar \
"
# build image
docker build --build-arg http_proxy=$http_proxy -t mesosphere/chronos:$image_tag .
if [ ! -z ${DOCKER_HUB_USERNAME+x} -a ! -z ${DOCKER_HUB_PASSWORD+x} ]; then
# login to dockerhub
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
# push image
docker push mesosphere/chronos:$image_tag
fi