forked from beeware/toga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·164 lines (141 loc) · 4.1 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
#!/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
# 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/^version = \".*\"/version = \"$2\"/g" temp > "$f"
git add "$f"
done
rm temp
pushd toga
mv setup.py temp
sed "s/version = .*/version = \"$2\"/g" temp > setup.py
git add setup.py
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 $1/src/toga
else
pushd $1/src/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
}
MODULES="android cocoa core dummy gtk iOS web winforms toga demo"
action=$1
shift
VERSION=$(grep "^__version__ = '.*'$" core/src/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" = "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:main
fi