summaryrefslogtreecommitdiff
path: root/scripts/mkrelease.py
blob: b5c4e846482b8f61756bd3856cb39ae00921ca8d (plain)
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
#!/usr/bin/env python
#
#
# create and upload a release
import os
import nose
import sys
from commands import getstatusoutput

success = 0

    
version = nose.__version__
svn_base_url = 'https://python-nose.googlecode.com/svn'
svn_trunk_url = 'https://python-nose.googlecode.com/svn/trunk'
svn_tags_url = 'https://python-nose.googlecode.com/svn/tags'

SIMULATE = 'exec' not in sys.argv
if SIMULATE:
    print("# simulated run: run as scripts/mkrelease.py exec "
          "to execute commands")

    
def runcmd(cmd):
    print cmd
    if not SIMULATE:
        (status,output) = getstatusoutput(cmd)
        if status != success:
            raise Exception(output)

        
def cd(dir):
    print "cd %s" % dir
    if not SIMULATE:
        os.chdir(dir)

    
def main():
    tag = 'release_%s' % version

    # create tag
    runcmd("hg tag -m 'Tagged release %s' %s" %
           (version, tag))
    
    # clone a fresh copy
    runcmd('hg clone -r %s . /tmp/nose_%s' % (tag, tag))

    # build release in clone
    cd('/tmp/nose_%s' % tag)
    
    # remove dev tag from setup
    runcmd('cp setup.cfg.release setup.cfg')

    # build included docs
    cd('doc')
    runcmd('make man readme')
    cd('..')
    
    # make the distribution
    runcmd('python setup.py sdist')

    # make the docs (don't want these included in sdist)
    cd('doc')
    runcmd('make html')
    cd('..')
    
    # upload docs and distribution
    if 'NOSE_UPLOAD' in os.environ:
        up = os.environ['NOSE_UPLOAD']
        cv = {
            'host': up[:up.index(':')],
            'path': up[up.index(':')+1:-1],
            'version':version,
            'upload': up,
            'upload_docs': os.path.join(up, version) }
        cv['versionpath'] = os.path.join(cv['path'], cv['version'])

        cmd = 'scp -C dist/nose-%(version)s.tar.gz %(upload)s' % cv
        runcmd(cmd)

        cmd = 'ssh %(host)s "mkdir -p %(versionpath)s"' % cv
        runcmd(cmd)
        
        cmd = ('scp -Cr doc/.build/html/* '
               '%(upload_docs)s/' % cv)
        runcmd(cmd)

        cmd = ('scp -C doc/index.html %(upload)s' % cv)
        runcmd(cmd)

if __name__ == '__main__':
    main()