-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·54 lines (46 loc) · 1.05 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
53
54
#!/usr/bin/env bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMAGE=ssh-proxy
build () {
echo "${DIR}"
cd "${DIR}"
docker build -t ${MY_DOCKER_HUB}/${IMAGE}:latest .
}
is_clean() {
if ! git diff --exit-code > /dev/null; then
echo "Git directory not clean. Aborting..."
echo
git diff
exit 1
fi
if [ "$(git ls-files --other --exclude-standard --directory)" -neq 0 ]; then
echo "Some files are not under version control. Aborting..."
echo
git ls-files --other --exclude-standard --directory
exit 1
fi
}
release() {
cd ${DIR}
is_clean
git pull
docker run --rm -v "${DIR}":/app treeder/bump patch
version=$(cat ${DIR}/VERSION)
build
git tag -a "${version}" -m "v${version}"
git push
git push --tags
docker tag ${MY_DOCKER_HUB}/${IMAGE}:latest ${MY_DOCKER_HUB}/${IMAGE}:${version}
docker push ${MY_DOCKER_HUB}/${IMAGE}:${version}
docker push ${MY_DOCKER_HUB}/${IMAGE}:latest
}
function_exists() {
declare -f -F $1 > /dev/null
return $?
}
if ! function_exists $1; then
echo "$1 is not an available command"
else
$1
fi