4 # Contact: grubert@users.sourceforge.net
7 # Copyright: This script has been placed in the public domain.
9 # USAGE see: docutils/docs/dev/release.txt
11 # must be run from docutils trunk/docutils,
12 # because HISTORY and RELEASE_NOTES.txt are modified.
16 function print_command
()
18 # Print "$@", quoting parameters containing spaces.
21 echo "$param" |
grep -Fq ' ' && echo -n " '$param'" ||
echo -n " $param"
35 # Print, let the user confirm and run "$@".
36 echo 'Press enter to run (or enter anything to skip):'
39 test "$REPLY" && echo Skipped. ||
"$@"
44 if test $svn == svk
; then
45 confirm svk sync
"$depot"
52 # Parameters: log_message, file, file, file ...
55 confirm
$svn diff "$@"
56 confirm
$svn ci
-m "$log_prefix $log_message" "$@"
61 # Parameters: old_version new_version
63 echo Determining list of files to be changed...
64 # BUG ls lists directories but does not descend
65 files
="docutils/__init__.py setup.py `$svn ls test/functional/expected/ | sed 's|^|test/functional/expected/|'`"
66 echo "Now I'll change the version number to $2 in the following files:"
69 echo 'Press enter to proceed (or enter anything to skip)...'
71 if [ ! "$REPLY" ]; then
72 echo 'Modifying files with ed...'
73 old_ver_regex
="`echo "$1" | sed 's/\./\\\\./g'`"
74 # "ed" returns an error code if there has been no substitution, so
75 # we temporarily deactivate exit-on-error.
78 (echo ",s/$old_ver_regex/$2/g"; echo 'wq') | ed
"$F"
83 echo 'CAUTION: please look at the diffs carefully, for wrongly'
84 echo ' replaced embedded numbers.'
85 checkin
"set version number to $2" $files
92 echo ' release.sh new_version svn_version[:branch_version] [stage]'
94 echo 'The following things will be done:'
96 echo '* Change version number to new_version. (stage 1)'
97 echo '* SVN-export, test, and release Docutils version new_version. (stage 2)'
98 echo '* Change version number to svn_version. (stage 3)'
100 echo 'If stage is supplied (1, 2 or 3), only the specified stage will'
101 echo 'be executed. Otherwise, it defaults to executing all stages.'
103 echo 'Before doing dangerous things, you will be asked to press enter.'
105 echo 'A maintenance branch called docutils-new_version will be created'
106 echo 'if branch_version is given. The version number inside the'
107 echo 'maintenance branch will be set to branch_version.'
109 echo 'Access ssh,scp and sftp access to shell/frs.sourceforge.net'
110 echo 'must be configured.'
114 function initialize
()
116 if [ "$#" -lt 2 ]; then
119 echo 'Initializing...'
120 python_versions
='2.6 2.7'
121 for py_ver
in $python_versions; do
122 echo -n "Checking for Python $py_ver (python$py_ver)... "
123 if ! echo 'print "OK"' | python
$py_ver; then
124 echo "WARN: Python $py_ver (python$py_ver) not found."
127 echo -n 'Clearing $PYTHONPATH... '
130 echo -n 'Checking whether we are in a working copy... '
131 if [ -f HISTORY.txt
]; then
134 echo "no (HISTORY.txt doesn't exist)"
136 echo 'Please cd to a working copy before running this script.'
139 echo -n 'Subversion binary to use: '
140 # TODO breaks for newer svn, .svn is in upper. is this for svk
143 working_copy
="`pwd -P`"
144 echo "Working copy: $working_copy"
145 svnurl
="`$svn info . | grep ^URL: | sed 's/URL: //'`"
146 if test -z "$svnurl"; then
147 echo 'Unable to detect Subversion URL. Aborting.'
150 echo "Subversion URL: $svnurl"
151 if ! echo "$svnurl" |
grep -q 'branches\|trunk'; then
152 echo 'Subversion URL contains neither "branches" nor "trunk".'
156 if test `uname` = "Darwin" ; then
157 svnroot
="`echo "$svnurl" | sed -E 's/\/(branches|trunk).*//'`"
159 svnroot
="`echo "$svnurl" | sed 's/\/\(branches\|trunk\).*//'`"
161 echo "Subversion root URL: $svnroot"
162 if test "$svnurl" = "$svnroot"; then
163 echo 'Error: Subversion URL and Subversion root URL are the same.'
164 echo ' probably a MacOSX sed problem.'
167 echo -n 'Detecting current Docutils version... '
168 old_ver
="`python -c 'import docutils; print docutils.__version__'`"
171 # log_prefix is for SVN logs.
172 log_prefix
="Release $new_ver:"
173 echo "New version number (for releasing): $new_ver"
175 if echo "$svn_ver" |
grep -q :; then
176 # Split at colon: svn_ver:branch_ver
177 branch_ver
="${svn_ver#*:}"
178 svn_ver
="${svn_ver%:*}"
182 echo "New Subversion version number (after releasing): $svn_ver"
183 echo -n 'Create maintenance branch: '
184 if test "$branch_ver"; then
186 echo "New version number on maintenance branch: $branch_ver"
190 if test "$branch_ver"; then
191 echo -n 'Checking that we have a full checkout... '
192 if echo "$working_copy" |
grep -q 'branches\|trunk'; then
196 echo 'Working copy path contains neither "branches" nor "trunk".'
197 echo 'You need a full checkout in order to branch.'
201 wcroot
="`echo "$working_copy" | sed 's/\/\(branches\|trunk\).*//'`"
202 echo "Working copy root: $wcroot"
204 tarball
=docutils-
"$new_ver".
tar.gz
205 echo "Tarball name: $tarball"
206 echo 'Initialization completed.'
210 function test_tarball
()
212 # Assume we have the tarball in the current directory.
213 # Pass test number as first parameter.
214 echo 'Testing the release tarball.'
215 run mkdir tarball_test
/
217 confirm
tar xzvf
"../$tarball"
219 run
cd docutils-
"$new_ver"
220 echo 'Deleteing old installations. Installing the distribution.'
221 echo "WARN: might not find installation."
222 for py_ver
in '"$python_versions"'; do
223 echo "python$py_ver install/update and test."
225 echo "Enter to test next."
230 function upload_tarball
()
232 # Assume we have the tarball in the working area.
233 run
cd "$working_area"
235 cp docutils-
$new_ver.
tar.gz
$new_ver
236 cp docutils
/RELEASE-NOTES.txt
$new_ver
237 # README.txt would be displayed automatically on sf.
238 # BUG user grubert hardcoded
239 # short path "/home/frs/project/docutils/docutils/" also exists
240 scp
-r $new_ver grubert
,docutils@frs.sourceforge.net
:/home
/frs
/project
/d
/do
/docutils
/docutils
/
241 echo 'Upload completed.'
244 function upload_htdocs
()
246 # Assume we have the tarball in the working area.
247 run
cd "$working_area"
248 echo "Upload htdocs for $new_ver"
251 confirm
tar xzvf
"../$tarball"
252 run
cd docutils-
"$new_ver"/tools
/
253 echo "BUG no docutils installation left."
254 echo "DO NOT call manually in $(pwd)"
255 confirm .
/buildhtml.py
--local ..
256 confirm .
/buildhtml.py ..
/docs
258 echo '$ find . -name test -type d -prune -o -name \*.css -print0 \
259 -o -name \*.html -print0 -o -name \*.txt -print0 \
260 | tar -cjvf docutils-docs.tar.bz2 -T - --null'
261 find .
-name test -type d
-prune -o -name \
*.css
-print0 \
262 -o -name \
*.html
-print0 -o -name \
*.txt
-print0 \
263 |
tar -cjvf docutils-docs.
tar.bz2
-T - --null
264 echo 'Upload docs to SF.net...'
265 echo 'Press enter (or enter anything to skip).'
267 if [ ! "$REPLY" ]; then
270 tar xjvf ..
/docutils-docs.
tar.bz2
272 chmod -R g
+rw
$new_ver
273 scp
-r -p -C $new_ver web.sourceforge.net
:/home
/groups
/d
/do
/docutils
/htdocs
277 function create_maintenance_branch
()
279 echo 'Creating maintenance branch.'
280 branch_name
="docutils-$new_ver"
281 echo "Branch name: $branch_name"
282 branch_url
="$svnroot/branches/$branch_name"
283 echo "Branch URL: $branch_url"
284 confirm svn
cp "$svnurl" "$branch_url" -m \
285 "$log_prefix created maintenance branch for version $new_ver"
288 cd branches
/"$branch_name"
289 set_ver
"$new_ver" "$branch_ver"
301 echo "Press enter to run stage $1 (or enter anything to skip this stage)."
303 if [ ! "$REPLY" ]; then
305 if [ "$1" == 1 ]; then
307 elif [ "$1" == 2 ]; then
309 elif [ "$1" == 3 ]; then
312 echo 'Invalid stage.'
317 echo "Stage $1 completed."
319 echo "Skipped stage $1."
328 # update __version_details__ string
329 (echo ",s/^__version_details__ = .*\$/__version_details__ = 'release'/";
330 echo wq
) | ed docutils
/__init__.py
2> /dev
/null
331 set_ver
"$old_ver" "$new_ver"
333 history_files
='HISTORY.txt RELEASE-NOTES.txt'
334 echo "Now updating the following files: $history_files"
335 old_string
="Changes Since [0-9.]+"
336 new_string
="Release $new_ver (`date --utc --iso-8601`)"
337 echo 'Press enter to replace "'"$old_string"'" with "'"$new_string"\",
338 echo 'or enter anything to skip.'
340 test "$REPLY" || python
-c "for filename in '$history_files'.split():
342 h = file(filename).read()
343 h = re.sub('$old_string\\n=+', '$new_string\\n' + '=' * len('$new_string'), h, count=1)
344 file(filename, 'w').write(h)"
345 checkin
'closed "Changes Since ..." section' $history_files
350 echo 'Creating working area...'
351 working_area
="`echo ~/tmp/docutils-release.$$`"
352 run mkdir
-p "$working_area"
354 echo 'Getting a fresh export.'
355 echo 'Press enter to proceed (or enter anything to skip)...'
357 if [ ! "$REPLY" ]; then
358 run
cd "$working_area"
359 confirm svn
export "$svnurl"
361 echo 'Building the release tarball.'
363 confirm .
/setup.py sdist
365 echo 'Tarball built.'
366 run
cp docutils
/dist
/"$tarball" .
367 echo 'BETTER run release-test.sh manually for each installed python version.'
368 echo "DO: cd $working_area and call sandbox/infrastructure/release-test.sh py_ver docutils_ver"
370 echo "Testing documentation and uploading htdocs of version $new_ver..."
371 confirm upload_htdocs
372 echo "Tagging current revision..."
373 confirm svn
cp "$svnurl" "$svnroot/tags/docutils-$new_ver/" -m "$log_prefix tagging released revision"
374 echo "Uploading $tarball to SF.net."
375 confirm upload_tarball
376 echo 'Now go to https://sourceforge.net/projects/docutils/files/docutils'
377 echo 'and follow the instructions at'
378 echo 'http://docutils.sf.net/docs/dev/release.html#file-release-system'
380 echo 'Then press enter.'
384 echo 'Downloading the tarball to verify its integrity.'
386 # BUG path is wrong. project admin filemanager shows md5sum
387 confirm wget http
://sourceforge.net
/projects
/docutils
/files
/"$tarball"
388 echo 'Was the download successful?'
389 echo 'If yes, press enter to continue, otherwise enter anything to repeat'
390 echo '(it is possible that the file will show up in a few minutes).'
392 test "$REPLY" ||
break
395 echo 'we are registered with PyPI...'
396 echo 'upload to pypi with twine or set download url for this release'
398 echo 'Press enter to proceed (or enter anything to skip)...'
400 if [ ! "$REPLY" ]; then
401 echo "Unpacking tarball..."
404 run twine upload
"$tarball"
405 echo "verify on PyPI. hide older releases."
406 echo "TODO TEST build wheels and upload"
407 run pip wheel docutils
408 run twine upload docutils-
*-py2-none-any.whl
409 run pip3 wheel docutils
410 run twine upload wheelhouse
/docutils-
${new_ver}-py3-none-any.whl
418 # update __version_details__ string
419 (echo ",s/^__version_details__ = .*\$/__version_details__ = 'repository'/";
420 echo wq
) | ed docutils
/__init__.py
2> /dev
/null
421 checkin
'set __version_details__ to "repository"'
423 history_files
='HISTORY.txt RELEASE-NOTES.txt'
424 echo "Now updating the following files: $history_files"
425 add_string
="Changes Since $new_ver"
427 echo 'Press enter to add "'"$add_string"'" section,'
428 echo 'or enter anything to skip.'
430 test "$REPLY" || python
-c "for filename in '$history_files'.split():
432 h = file(filename).read()
433 h = re.sub('\n$before', '\\n$add_string\\n' + '=' * len('$add_string') +
434 '\\n\\n\\n$before', h, count=1)
435 file(filename, 'w').write(h)"
436 checkin
"added empty \"Changes Since $new_ver\" section" $history_files
438 if test "$branch_ver"; then
439 create_maintenance_branch
442 set_ver
"$new_ver" "$svn_ver"
443 echo 'Please change version number in README.txt'
445 echo 'Please update the web page now (web/index.txt).'
446 echo 'cd into sandbox/infrastructure'
447 echo 'and call docutils-update.local (requires linux, macosx cp misses something)'
448 echo "Press enter when you're done."
456 echo 'Run alltests.py on svn version now.'
459 # indent-tabs-mode: nil