forked from beeware/toga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·189 lines (163 loc) · 4.88 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash
# Force the script to fail on any error
set -e
function bump {
echo
echo "************************************************************"
echo "***** BUMP $1 version $2 *****"
echo "************************************************************"
echo
if [ "$1" = "toga" ]; then
pushd .
# Find all the pyproject.toml examples,
# and update the version of toga required.
find examples -name pyproject.toml | while read f; do
mv "$f" temp
sed "s/==.*\"/==$2\"/g" temp > "$f"
mv "$f" temp
sed "s/^version = \".*\"/version = \"$2\"/g" temp > "$f"
git add "$f"
done
elif [ "$1" = "demo" ]; then
pushd demo
mv setup.cfg temp
sed "s/version = .*/version = $2/g" temp > setup.cfg
mv setup.cfg temp
sed "s/toga==.*/toga==$2/g" temp > setup.cfg
git add setup.cfg
mv pyproject.toml temp
sed "s/==.*\"/==$2\"/g" temp > pyproject.toml
mv pyproject.toml temp
sed "s/^version = \".*\"/version = \"$2\"/g" temp > pyproject.toml
git add pyproject.toml
else
if [ "$1" = "core" ]; then
pushd src/$1/toga
else
pushd src/$1/toga_$1
fi
mv __init__.py temp
sed "s/^__version__ = '.*'/__version__ = '$2'/g" temp > __init__.py
git add __init__.py
fi
rm temp
popd
}
function package {
echo
echo "************************************************************"
echo "***** PACKAGE $1"
echo "************************************************************"
echo
if [ "$1" = "toga" ]; then
rm -rf build dist
check-manifest -v
python setup.py sdist bdist_wheel
python -m twine check dist/*
elif [ "$1" = "demo" ]; then
cd demo
check-manifest -v
rm -rf build dist
python setup.py sdist bdist_wheel
cd ../..
else
cd src/$1
check-manifest -v
rm -rf build dist
python setup.py sdist bdist_wheel
python -m twine check dist/*
cd ../..
fi
}
function install {
echo
echo "************************************************************"
echo "INSTALL $1"
echo "************************************************************"
echo
if [ "$1" = "toga" ]; then
python -m pip install dist/*.whl
elif [ "$1" = "demo" ]; then
python -m pip install demo/dist/*.whl
else
python -m pip install src/$1/dist/*.whl
fi
}
function release {
echo
echo "************************************************************"
echo "RELEASE $1 version $2"
echo "************************************************************"
echo
if [ "$1" = "toga" ]; then
twine upload "dist/toga-$2-py3-none-any.whl"
twine upload "dist/toga-$2.tar.gz"
elif [ "$1" = "demo" ]; then
twine upload "demo/dist/toga_demo-$2-py3-none-any.whl"
twine upload "demo/dist/toga-demo-$2.tar.gz"
else
twine upload "src/$1/dist/toga_$1-$2-py3-none-any.whl"
twine upload "src/$1/dist/toga-$1-$2.tar.gz"
fi
}
MODULES="android cocoa core django dummy flask gtk iOS web winforms toga demo"
action=$1
shift
VERSION=$(grep "^__version__ = '.*'$" src/core/toga/__init__.py | cut -f 2 -d \')
if [ "$action" = "" ]; then
echo "Usage -"
echo
echo " Bump version number for release:"
echo " ./release.sh bump 1.2.3"
echo
echo " Package the release"
echo " ./release.sh package"
echo
echo " Set up a test environment containing the release"
echo " ./release.sh test"
echo
echo " Release the build products and tag the repo."
echo " ./release.sh release"
echo
echo " Bump version number for next development version (dev3)"
echo " ./release.sh dev 1.2.4 3"
elif [ "$action" = "package" ]; then
for module in $MODULES; do
package $module
done
elif [ "$action" = "test" ]; then
python -m venv testenv-v$VERSION
source testenv-v$VERSION/bin/activate
for module in $MODULES; do
install $module
done
elif [ "$action" = "release" ]; then
for module in $MODULES; do
$action $module $VERSION
done
git tag v$VERSION
git push upstream release:master
git push --tags upstream release:master
elif [ "$action" = "bump" ]; then
version=$1
shift
git pull
for module in $MODULES; do
$action $module $version
done
git commit -m "Bumped version number for v$version release."
elif [ "$action" == "dev" ]; then
version=$1
shift
dev=$1
shift
if [ -z "$dev" ]; then
dev=1
fi
git pull
for module in $MODULES; do
bump $module $version.dev$dev
done
git commit -m "Bumped version number for v$version.dev$dev development."
git push upstream release:master
fi