release.py: Allow for a dry-run to double-check the results

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-05-18 02:55:23 -04:00
parent b82e22b019
commit d09a4cbbc5

View File

@ -28,8 +28,10 @@ def system(sh, errmsg=None):
error(errmsg + ' (error code: %s)' % ret) error(errmsg + ' (error code: %s)' % ret)
def usage(): def usage():
error('Usage: %s [-s] <sf username> <version>\nSpecify -s to pass it on ' error('Usage: %s [-s|-n] <sf username> <version>\nSpecify -s to pass it on '
'to the relevant git commands.\nMust be called from a git checkout.' 'to the relevant git commands.\nSpecify -n to perform a dry-run '
'release. No commits or tags are pushed and no files are uploaded.'
'\nMust be called from a git checkout.'
% sys.argv[0]) % sys.argv[0])
def checkGitRepo(): def checkGitRepo():
@ -44,16 +46,20 @@ def checkGitRepo():
'Your tree is unclean. Can\'t run from here.') 'Your tree is unclean. Can\'t run from here.')
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 3 or len(sys.argv) > 4: if len(sys.argv) < 3 or len(sys.argv) > 5:
usage() usage()
checkGitRepo() checkGitRepo()
sign = '' sign = ''
if len(sys.argv) == 4: dryrun = False
while len(sys.argv) > 3:
if sys.argv[1] == '-s': if sys.argv[1] == '-s':
sign = '-s' sign = '-s'
sys.argv.pop(1) sys.argv.pop(1)
elif sys.argv[1] == '-n':
dryrun = True
sys.argv.pop(1)
else: else:
usage() usage()
@ -101,9 +107,10 @@ if __name__ == '__main__':
system('git commit %s -m \'Updated to %s.\' %s' system('git commit %s -m \'Updated to %s.\' %s'
% (sign, v, ' '.join(versionFiles))) % (sign, v, ' '.join(versionFiles)))
print 'Pushing commits.' if not dryrun:
system('git push origin master') print 'Pushing commits and tag.'
system('git push --tags') system('git push origin master')
system('git push --tags')
print 'Creating tarball (gzip).' print 'Creating tarball (gzip).'
system('git archive --prefix=Supybot-%s/ --format=tar %s ' system('git archive --prefix=Supybot-%s/ --format=tar %s '
@ -118,14 +125,15 @@ if __name__ == '__main__':
os.chdir('..') os.chdir('..')
shutil.rmtree('supybot') shutil.rmtree('supybot')
print 'Uploading package files to upload.sf.net.' if not dryrun:
system('scp Supybot-%s.tar.gz Supybot-%s.tar.bz2 Supybot-%s.zip ' print 'Uploading package files to upload.sf.net.'
'%s@frs.sourceforge.net:uploads' % (v, v, v, u)) system('scp Supybot-%s.tar.gz Supybot-%s.tar.bz2 Supybot-%s.zip '
'%s@frs.sourceforge.net:uploads' % (v, v, v, u))
print 'Copying new version.txt over to project webserver.' print 'Copying new version.txt over to project webserver.'
system('echo %s > version.txt' % v) system('echo %s > version.txt' % v)
system('scp version.txt %s@shell.sf.net:/home/groups/s/su/supybot/htdocs'%u) system('scp version.txt %s@shell.sf.net:/home/groups/s/su/supybot/htdocs'%u)
system('rm version.txt') system('rm version.txt')
# print 'Generating documentation.' # print 'Generating documentation.'
# # docFiles is in the format {directory: files} # # docFiles is in the format {directory: files}