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.4 2.5 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 svnroot
="`echo "$svnurl" | sed 's/\/\(branches\|trunk\).*//'`"
157 echo "Subversion root URL: $svnroot"
158 if test "$svnurl" = "$svnroot"; then
159 echo 'Error: Subversion URL and Subversion root URL are the same.'
160 echo ' probably a MacOSX sed problem.'
163 echo -n 'Detecting current Docutils version... '
164 old_ver
="`python -c 'import docutils; print docutils.__version__'`"
167 # log_prefix is for SVN logs.
168 log_prefix
="Release $new_ver:"
169 echo "New version number (for releasing): $new_ver"
171 if echo "$svn_ver" |
grep -q :; then
172 # Split at colon: svn_ver:branch_ver
173 branch_ver
="${svn_ver#*:}"
174 svn_ver
="${svn_ver%:*}"
178 echo "New Subversion version number (after releasing): $svn_ver"
179 echo -n 'Create maintenance branch: '
180 if test "$branch_ver"; then
182 echo "New version number on maintenance branch: $branch_ver"
186 if test "$branch_ver"; then
187 echo -n 'Checking that we have a full checkout... '
188 if echo "$working_copy" |
grep -q 'branches\|trunk'; then
192 echo 'Working copy path contains neither "branches" nor "trunk".'
193 echo 'You need a full checkout in order to branch.'
197 wcroot
="`echo "$working_copy" | sed 's/\/\(branches\|trunk\).*//'`"
198 echo "Working copy root: $wcroot"
200 tarball
=docutils-
"$new_ver".
tar.gz
201 echo "Tarball name: $tarball"
202 echo 'Initialization completed.'
206 function test_tarball
()
208 # Assume we have the tarball in the current directory.
209 # Pass test number as first parameter.
210 echo 'Testing the release tarball.'
211 run mkdir tarball_test
/
213 confirm
tar xzvf
"../$tarball"
215 run
cd docutils-
"$new_ver"
216 echo 'Deleteing old installations. Installing the distribution.'
217 echo "WARN: might not find installation."
218 for py_ver
in '"$python_versions"'; do
219 echo "python$py_ver install/update and test."
221 echo "Enter to test next."
226 function upload_tarball
()
228 # Assume we have the tarball in the working area.
229 run
cd "$working_area"
231 cp docutils-
$new_ver.
tar.gz
$new_ver
232 cp docutils
/RELEASE-NOTES.txt
$new_ver
233 # README.txt would be displayed automatically on sf.
234 # BUG user grubert hardcoded
235 # short path "/home/frs/project/docutils/docutils/" also exists
236 scp
-r $new_ver grubert
,docutils@frs.sourceforge.net
:/home
/frs
/project
/d
/do
/docutils
/docutils
/
237 echo 'Upload completed.'
240 function upload_htdocs
()
242 # Assume we have the tarball in the working area.
243 run
cd "$working_area"
244 echo "Upload htdocs for $new_ver"
247 confirm
tar xzvf
"../$tarball"
248 run
cd docutils-
"$new_ver"/tools
/
249 echo "BUG no docutils installation left."
250 echo "DO NOT let call but manually in $(pwd)"
251 confirm .
/buildhtml.py
--local ..
252 confirm .
/buildhtml.py ..
/docs
254 echo '$ find -name test -type d -prune -o -name \*.css -print0 \
255 -o -name \*.html -print0 -o -name \*.txt -print0 \
256 | tar -cjvf docutils-docs.tar.bz2 -T - --null'
257 find -name test -type d
-prune -o -name \
*.css
-print0 \
258 -o -name \
*.html
-print0 -o -name \
*.txt
-print0 \
259 |
tar -cjvf docutils-docs.
tar.bz2
-T - --null
260 echo 'Upload docs to SF.net...'
261 echo 'Press enter (or enter anything to skip).'
263 if [ ! "$REPLY" ]; then
266 tar xjvf ..
/docutils-docs.
tar.bz2
268 chmod -R g
+rw
$new_ver
269 scp
-r -p -C $new_ver web.sourceforge.net
:/home
/groups
/d
/do
/docutils
/htdocs
273 function create_maintenance_branch
()
275 echo 'Creating maintenance branch.'
276 branch_name
="docutils-$new_ver"
277 echo "Branch name: $branch_name"
278 branch_url
="$svnroot/branches/$branch_name"
279 echo "Branch URL: $branch_url"
280 confirm svn
cp "$svnurl" "$branch_url" -m \
281 "$log_prefix created maintenance branch for version $new_ver"
284 cd branches
/"$branch_name"
285 set_ver
"$new_ver" "$branch_ver"
297 echo "Press enter to run stage $1 (or enter anything to skip this stage)."
299 if [ ! "$REPLY" ]; then
301 if [ "$1" == 1 ]; then
303 elif [ "$1" == 2 ]; then
305 elif [ "$1" == 3 ]; then
308 echo 'Invalid stage.'
313 echo "Stage $1 completed."
315 echo "Skipped stage $1."
324 # update __version_details__ string
325 (echo ",s/^__version_details__ = .*\$/__version_details__ = 'release'/";
326 echo wq
) | ed docutils
/__init__.py
2> /dev
/null
327 set_ver
"$old_ver" "$new_ver"
329 history_files
='HISTORY.txt RELEASE-NOTES.txt'
330 echo "Now updating the following files: $history_files"
331 old_string
="Changes Since [0-9.]+"
332 new_string
="Release $new_ver (`date --utc --iso-8601`)"
333 echo 'Press enter to replace "'"$old_string"'" with "'"$new_string"\",
334 echo 'or enter anything to skip.'
336 test "$REPLY" || python
-c "for filename in '$history_files'.split():
338 h = file(filename).read()
339 h = re.sub('$old_string\\n=+', '$new_string\\n' + '=' * len('$new_string'), h, count=1)
340 file(filename, 'w').write(h)"
341 checkin
'closed "Changes Since ..." section' $history_files
346 echo 'Creating working area...'
347 working_area
="`echo ~/tmp/docutils-release.$$`"
348 run mkdir
-p "$working_area"
350 echo 'Getting a fresh export.'
351 echo 'Press enter to proceed (or enter anything to skip)...'
353 if [ ! "$REPLY" ]; then
354 run
cd "$working_area"
355 confirm svn
export "$svnurl"
357 echo 'Building the release tarball.'
359 confirm .
/setup.py sdist
361 echo 'Tarball built.'
362 run
cp docutils
/dist
/"$tarball" .
363 echo 'BETTER run release-test.sh manually for each installed python version.'
364 echo "DO: cd $working_area and call sandbox/infrastructure/release-test.sh py_ver docutils_ver"
366 echo "Testing documentation and uploading htdocs of version $new_ver..."
367 confirm upload_htdocs
368 echo "Tagging current revision..."
369 confirm svn
cp "$svnurl" "$svnroot/tags/docutils-$new_ver/" -m "$log_prefix tagging released revision"
370 echo "Uploading $tarball to SF.net."
371 confirm upload_tarball
372 echo 'Now go to https://sourceforge.net/projects/docutils/files/docutils'
373 echo 'and follow the instructions at'
374 echo 'http://docutils.sf.net/docs/dev/release.html#file-release-system'
376 echo 'Then press enter.'
380 echo 'Downloading the tarball to verify its integrity.'
382 # BUG path is wrong. project admin filemanager shows md5sum
383 confirm wget http
://sourceforge.net
/projects
/docutils
/files
/"$tarball"
384 echo 'Was the download successful?'
385 echo 'If yes, press enter to continue, otherwise enter anything to repeat'
386 echo '(it is possible that the file will show up in a few minutes).'
388 test "$REPLY" ||
break
391 echo 'Registering with PyPI...'
392 echo 'TODO upload to pypi or set download url for this release'
393 echo 'Press enter to proceed (or enter anything to skip)...'
395 if [ ! "$REPLY" ]; then
396 echo "Unpacking tarball..."
399 run
tar xzvf
"$tarball"
400 run
cd docutils-
"$new_ver"
401 echo 'TODO upload to pypi'
402 confirm .
/setup.py register
410 # update __version_details__ string
411 (echo ",s/^__version_details__ = .*\$/__version_details__ = 'repository'/";
412 echo wq
) | ed docutils
/__init__.py
2> /dev
/null
413 checkin
'set __version_details__ to "repository"'
415 history_files
='HISTORY.txt RELEASE-NOTES.txt'
416 echo "Now updating the following files: $history_files"
417 add_string
="Changes Since $new_ver"
419 echo 'Press enter to add "'"$add_string"'" section,'
420 echo 'or enter anything to skip.'
422 test "$REPLY" || python
-c "for filename in '$history_files'.split():
424 h = file(filename).read()
425 h = re.sub('\n$before', '\\n$add_string\\n' + '=' * len('$add_string') +
426 '\\n\\n\\n$before', h, count=1)
427 file(filename, 'w').write(h)"
428 checkin
"added empty \"Changes Since $new_ver\" section" $history_files
430 if test "$branch_ver"; then
431 create_maintenance_branch
434 set_ver
"$new_ver" "$svn_ver"
435 echo 'Please change version number in README.txt'
437 echo 'Please update the web page now (web/index.txt).'
438 echo 'cd into sandbox/infrastructure'
439 echo 'and call docutils-update.local (requires linux, macosx cp misses something)'
440 echo "Press enter when you're done."
448 echo 'Run alltests.py on svn version now.'
451 # indent-tabs-mode: nil