-
Notifications
You must be signed in to change notification settings - Fork 9
/
release.sh
81 lines (63 loc) · 1.62 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
#!/bin/bash
# Releases COW to pypi via specified tag
CURRENT_TAG=$(git tag | tail -n1)
# test if we have access to twine
if [ -z "$TWINE_PATH" ];
then
TWINE_PATH=$(command -v twine)
if [ $? -eq 0 ];
then
# found a system binary
break
elif [ ! $(python3 -m twine &> /dev/null ; echo $?) ];
then
# found a Python module
TWINE_PATH="python3 -m twine"
else
# check for virtual environment on current and higher level
TWINE_PATH=$(find ../ -type f -name twine)
if [ $(echo "$TWINE_PATH" | wc -l) -ne 1 ];
then
echo "Cannot find Python module 'twine'."
echo "Please install twine or run this script with 'env TWINE_PATH=...' to specify its location."
exit 2
fi
fi
fi
function do_update () {
echo ' - uploading tags'
git tag "$1" -m "Release of COW $1"
git push --tags origin base
sleep 1
echo ' - updating documentation'
sed -i "s/\(version\s=\s'\)[0-9]\+\.[0-9]\+\('\)/\1$1\2/" setup.py src/csvw_tool.py
sleep 1
echo ' - cleaning outdated cache'
rm -rf dist/ local/
sleep 1
echo ' - preparing new distibution'
python3 setup.py sdist
sleep 1
echo ' - uploading update to PiPy (using $TWINE_PATH)'
"$TWINE_PATH" upload dist/*
sleep 1
echo ' - cleaning cache'
rm -rf dist/ local/
}
echo "============================================"
echo " CSV On the Web (COW) - Release update tool "
echo "============================================"
echo "current tag: $CURRENT_TAG"
echo -n "new tag: "
read NEW_TAG
echo -n "Release update under tag: $NEW_TAG ? ( Y / [N] ) "
read UPDATE
case "$UPDATE" in
y|Y|yes|Yes)
do_update "$NEW_TAG"
;;
*)
exit 1
;;
esac
exit 0