forked from houtianze/bypy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·152 lines (130 loc) · 2.38 KB
/
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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo !!! RUN THIS SCRIPT UNDER VIRTUALENV !!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# need to run the following commands before running this release script
# (This is for macOS, and for python virtualenv is recommended)
# --------
# brew install pandoc
# pip3 install pandoc pypandoc twine pyflakes
### Usage ###
# - Testing: ./release.sh -buti
# - Actual: ./release.sh -abigtu
#set -o errexit
#set -x
trap "echo '=== Release script interrupted ==='; exit 255" INT
check() {
command -v "$1" || { echo "'$1' doesn't exist, aborting."; exit 255; }
}
pycmd=python3
check git
check $pycmd
check pandoc
check pyflakes
check twine
check jq
actual=0
build=0
install=0
upload=0
testit=0
tagit=0
parsearg() {
while getopts "abigtu" opt; do
case "$opt" in
a)
actual=1
;;
b)
build=1
;;
u)
upload=1
;;
i)
install=1
;;
t)
testit=1
;;
g)
tagit=1
;;
*)
echo "Invalid arguments."
exit 255
;;
esac
done
}
runtest() {
eval $pycmd -m pyflakes bypy
eval $pycmd setup.py test
#eval $pycmd -m doctest -v bypy.py
eval $pycmd -m bypy -V
# eval $pycmd -m bypy --config-dir bypy/test/configdir quota
}
installtest() {
# due to requests not in testpypi
if [ $actual -eq 0 ]
then
pip install requests
else
pip uninstall -y requests
fi
pip uninstall -y bypy
if [ -z "$indexopt" ]
then
pip install -U bypy
else
pip install -U bypy "$indexopt"
fi
bypy -V
# bypy --config-dir bypy/test/configdir quota
}
main() {
./syncver.sh
eval $pycmd genrst.py
parsearg "$@"
if [ "$actual" -eq 0 ]
then
repoopt="-r testpypi"
indexopt="-ihttps://testpypi.python.org/simple/"
else
repoopt=""
indexopt=""
fi
if [ "$tagit" -eq 1 ]
then
# shellcheck disable=SC2006
bypyversion=`grep __version__ bypy/const.py | sed -e "s/__version__ *= *'//g" -e "s/'//g"`
git --no-pager tag
git tag "$bypyversion"
git push
git push --tags
git --no-pager tag
fi
if [ "$testit" -eq 1 ]
then
runtest
fi
if [ "$build" -eq 1 ]
then
rm dist/*
eval $pycmd setup.py clean --all
eval $pycmd setup.py bdist_wheel #sdist
fi
uploadcmd="twine upload dist/* $repoopt"
if [ "$upload" -eq 0 ]
then
echo "$uploadcmd"
else
eval "$uploadcmd"
fi
if [ "$install" -eq 1 ]
then
installtest
fi
}
main "$@"
# vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 ff=unix fileencoding=utf-8