summaryrefslogtreecommitdiff
path: root/contrib/internal/release.py
blob: eb156ebd395d97152f3184b56fd8b2b93c2c047a (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
#!/usr/bin/env python
#
# Performs a release of Review Board. This can only be run by the core
# developers with release permissions.
#

import os
import re
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
from rbtools import get_package_version, VERSION


PY_VERSIONS = ["2.4", "2.5", "2.6"]

LATEST_PY_VERSION = PY_VERSIONS[-1]

PACKAGE_NAME = 'RBTools'

RELEASES_URL = \
    'reviewboard.org:/var/www/downloads.reviewboard.org/' \
    'htdocs/releases/%s/%s.%s/' % (PACKAGE_NAME, VERSION[0], VERSION[1])


built_files = []


def execute(cmdline):
    print ">>> %s" % cmdline

    if os.system(cmdline) != 0:
        print "!!! Error invoking command."
        sys.exit(1)


def run_setup(target, pyver = LATEST_PY_VERSION):
    execute("python%s ./setup.py release %s" % (pyver, target))


def build_targets():
    for pyver in PY_VERSIONS:
        run_setup("bdist_egg", pyver)
        built_files.append("dist/%s-%s-py%s.egg" %
                           (PACKAGE_NAME, get_package_version(), pyver))

    run_setup("sdist")
    built_files.append("dist/%s-%s.tar.gz" %
                       (PACKAGE_NAME, get_package_version()))


def upload_files():
    execute("scp %s %s" % (" ".join(built_files), RELEASES_URL))


def tag_release():
    execute("git tag release-%s" % get_package_version())


def register_release():
    run_setup("register")


def main():
    if not os.path.exists("setup.py"):
        sys.stderr.write("This must be run from the root of the "
                         "Djblets tree.\n")
        sys.exit(1)

    build_targets()
    upload_files()
    tag_release()
    register_release()


if __name__ == "__main__":
    main()