-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
push.sh
executable file
·61 lines (51 loc) · 1.75 KB
/
push.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
#!/usr/bin/env bash
#
# Build image from the currently checked out version of
# MusicBrainz Solr search server (mb-solr)
# and push it to Docker Hub, tagged with versions and variants.
#
# Examples:
# - working tree at git tag v3.1.1 will push docker tags :3.1.1 :3.1 and :3
# - working tree at git tag v3.1.1-rc.1 will push docker tag :3.1.1-rc.1 only
# - untagged working tree v3.1-1-gbfe66e3 will push docker tag 3.1.1-gbfe66e3 only
# - uncommitted/dirty working tree v3.1-dirty will push docker tag :3.1-dirty only
#
# This script is purposed for maintainers only, not contributors.
#
# Usage:
# $ ./push.sh
set -e -u
image_name='metabrainz/mb-solr'
cd "$(dirname "${BASH_SOURCE[0]}")/"
DOCKER_CMD=${DOCKER_CMD:-docker}
vcs_ref=`git describe --always --broken --dirty --tags`
version=${vcs_ref#v}
# enforce version format major.minor.patch if possible
if [[ $version =~ ^[0-9]+$ ]]; then
version="${version}.0.0"
echo "$0: appended .0.0 to version"
elif [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then
version="${version}.0"
echo "$0: appended .0 to version"
fi
# add aliases if version is of format major.minor.patch
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.[0-9]+$ ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
version_aliases=( "${major}.${minor}" "${major}" )
echo "$0: building version '$version' with aliases:"
for version_alias in ${version_aliases[@]}; do
echo "$0: - '$version_alias'"
done
else
version_aliases=()
echo "$0: building version '$version' without alias"
fi
tag=${version}
tag_aliases=${version_aliases[@]}
./build.sh
${DOCKER_CMD} push ${image_name}:${tag}
for tag_alias in ${tag_aliases[@]}; do
${DOCKER_CMD} tag ${image_name}:${tag} metabrainz/mb-solr:${tag_alias}
${DOCKER_CMD} push ${image_name}:${tag_alias}
done