-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·119 lines (101 loc) · 2.79 KB
/
build.sh
File metadata and controls
executable file
·119 lines (101 loc) · 2.79 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
TWINE_USERNAME=nearbydelta
extract_version()
{
LIB_VER=$(cat setup.py | grep "version=" | cut -d\' -f2 | cut -d- -f1)
LIB_VER_MAJOR=$(echo $LIB_VER | cut -d. -f1)
LIB_VER_MINOR=$(echo $LIB_VER | cut -d. -f2)
LIB_VER_INCRM=$(echo $LIB_VER | cut -d. -f3)
LIB_VER_CURRENT=$LIB_VER_MAJOR.$LIB_VER_MINOR.$LIB_VER_INCRM
}
add_incremental_ver()
{
LIB_VER_NEXT=$LIB_VER_MAJOR.$LIB_VER_MINOR.$(($LIB_VER_INCRM + 1))
}
add_minor_ver()
{
LIB_VER_NEXT=$LIB_VER_MAJOR.$(($LIB_VER_MINOR + 1)).0
}
set_version()
{
cat setup.py | sed -e "s/version=\s*'.*'/version='$1'/g" > setup.py.new
rm setup.py
mv setup.py.new setup.py
git add setup.py
cat doc_source/conf.py | sed -e "s/release\s*=\s*'.*'/release = '$1'/g" > doc_source/conf.new
rm doc_source/conf.py
mv doc_source/conf.new doc_source/conf.py
git add doc_source/conf.py
}
ask_proceed()
{
read -p "Proceed $1 [Y/n/p]? " YN
if [ "${YN,,}" = "n" ]; then
exit 0
fi
}
pip_upgrade()
{
read -p "Does this system requires superuser privileges for upgrade Pypi packages [y/N]? " SUDO
if [ "${SUDO,,}" = "y" ]; then
sudo -H pip3 install --upgrade sphinx sphinx_rtd_theme twine pytest pypandoc wheel
else
pip3 install --upgrade sphinx sphinx_rtd_theme twine pytest pypandoc wheel
fi
}
ask_proceed "PIP upgrade"
if [ "${YN,,}" != "p" ]; then
pip_upgrade
fi
ask_proceed "Test"
if [ "${YN,,}" != "p" ]; then
python3 -m pytest tests/finalize_test.py
python3 -m pytest tests/multi_processing_test.py
python3 -m pytest tests/data_test.py
python3 -m pytest tests/dictionary_test.py
python3 -m pytest tests/extension_core_spec.py
python3 -m pytest tests/proc_core_spec.py
python3 -m pytest tests/type_core_spec.py
python3 -m pytest tests/khaiii_spec.py
python3 -m pytest tests/utagger_spec.py
python3 -m pytest tests/native_spec.py
fi
extract_version
echo $LIB_VER_CURRENT
ask_proceed "Set Current Version"
if [ "${YN,,}" != "p" ]; then
set_version $LIB_VER_CURRENT
fi
ask_proceed "Build document"
if [ "${YN,,}" != "p" ]; then
mv docs/.nojekyll ./
mv docs/index.html ./
make clean
make html
mv ./.nojekyll docs/
mv ./index.html docs/
fi
ask_proceed "Build package"
if [ "${YN,,}" != "p" ]; then
rm -r dist/
python3 setup.py bdist_wheel
git add .
git commit -m "Release: v$LIB_VER_CURRENT"
git tag v$LIB_VER_CURRENT
fi
ask_proceed "Upload package"
if [ "${YN,,}" != "p" ]; then
twine upload dist/koalanlp-*.whl
fi
ask_proceed "Set Next"
if [ "${YN,,}" != "p" ]; then
add_incremental_ver
set_version "$LIB_VER_NEXT-SNAPSHOT"
fi
ask_proceed "Commit"
if [ "${YN,,}" != "p" ]; then
git add .
git commit -m "Initial commit for v$LIB_VER_NEXT"
git push --all
git push --tags
fi