forked from couchbase/tlm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_release.py
executable file
·55 lines (43 loc) · 1.55 KB
/
tag_release.py
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
#!/usr/bin/env python
"""Script to tag projects with the release from the manifest.
Requires: Permission to push tags to Gerrit
Usage: Run from the top of a repo checkout:
tag_release.py <release> <projects..>
e.g.
tag_release.py 4.0.0 memcached platform
This will print the commands needed to tag the release.
Review, then copy/paste.
"""
import os
import sys
import xml.etree.ElementTree
if len(sys.argv) < 3:
print >> sys.stderr, "Usage: {} <release> <projects...>".format(
sys.argv[0])
exit(1)
release = sys.argv[1]
manifest_path = None
manifest_subdirs = ["released/", "released/couchbase-server/"]
for subdir in manifest_subdirs:
path = ".repo/manifests/" + subdir + release + ".xml"
if os.path.exists(path):
manifest_path = path
break
if not manifest_path:
print >> sys.stderr, "Unable to locate manifest '" + release + ".xml' - searched in:"
for subdir in manifest_subdirs:
print >> sys.stderr, "\t" + subdir
print >> sys.stderr, "Check specified release and current working " \
"directory (should be run from top-level of repo checkout)."
exit(2)
projects_to_tag = sys.argv[2:]
e = xml.etree.ElementTree.parse(manifest_path).getroot()
for p in e.findall('project'):
if p.attrib['name'] in projects_to_tag:
name = p.attrib['name']
sha = p.attrib['revision']
print "pushd " + name
print """git tag -a -m "{0} release ({1})" v{0} {2}""".format(
release, name, sha)
print "git push review v{0}".format(release)
print "popd"