-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish_enterprise.sh
executable file
·100 lines (88 loc) · 2.33 KB
/
publish_enterprise.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
pip install build
source ./pip_common.sh
# -------------------------------------
VER="${VER:-$1}" # If VER is not defined, try arg 1
[ "${VER}" == '${bamboo.jira.version}' ] && unset VER # = "0.0.0dev${BUILD}"
VER="${VER:?You must pass a version of the format 0.0.0 as the only argument}"
SRC_PATH="${2:-..}"
function convertBambooDate() {
# EG s="2010-01-01T01:00:00.000+01:00"
# TO 100101.0100
python <<EOF
from dateutil.parser import parse
print parse("${BAMBOO_DATE}").strftime('%y%m%d.%H%M')
EOF
}
#echo "start version is $VER"
#BUILD="${BUILD:-0}" # Default to build 0
#VER="${VER}"
if [ "${BAMBOO_DATE:-}" ]
then
DATE="$(convertBambooDate)"
else
DATE="$(date +%y%m%d.%H%M)"
fi
#echo "New version is $VER"
#echo "New build is $BUILD"
# -------------------------------------
echo "CHECKING for package existance"
EXIT=""
for plugin in $ENTERPRISE_PKGS
do
if [ ! -d "${SRC_PATH}/$plugin" ]
then
echo "${bold}${plugin}${normal} : $plugin does not exist" >&2
EXIT="Y"
fi
done
echo
[ -n "$EXIT" ] && exit 1
# -------------------------------------
echo "CHECKING for uncommitted changes"
EXIT=""
for plugin in $ENTERPRISE_PKGS
do
if [ -n "$(cd ${SRC_PATH}/$plugin && git status --porcelain)" ]
then
echo "${bold}${plugin}${normal} : has uncomitted changes, make sure all changes are comitted" >&2
EXIT="Y"
fi
done
echo
[ -n "$EXIT" ] && exit 1
# -------------------------------------
echo "CHECKING for existing tag"
EXIT=""
for plugin in $ENTERPRISE_PKGS
do
if (cd ${SRC_PATH}/$plugin && git tag | grep -q "^${VER}$")
then
echo "${bold}${plugin}${normal} : has an existing git tag for version ${VER}." >&2
EXIT="Y"
fi
done
echo
[ -n "$EXIT" ] && exit 1
# -------------------------------------
echo "CHECKING for for successful build"
for plugin in $ENTERPRISE_PKGS
do
if ! (cd ${SRC_PATH}/$plugin && python -m build --sdist)
then
echo "${bold}${plugin}${normal} : failed to build." >&2
exit 1
fi
done
echo
# -------------------------------------
echo "Building packages"
for plugin in $ENTERPRISE_PKGS
do
if ! (cd ${SRC_PATH}/$plugin && bash publish.sh ${VER} "")
then
echo "${bold}${plugin}${normal} : failed to run publish." >&2
exit 1
fi
done
echo