-
Notifications
You must be signed in to change notification settings - Fork 46
/
tag_release.py
executable file
·65 lines (51 loc) · 1.93 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
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""
Copyright 2015-Present Couchbase, Inc.
Use of this software is governed by the Business Source License included in
the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that
file, in accordance with the Business Source License, use of this software will
be governed by the Apache License, Version 2.0, included in the file
licenses/APL2.txt.
"""
"""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("Usage: {} <release> <projects...>".format(
sys.argv[0]), file=sys.stderr)
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("Unable to locate manifest '" + release + ".xml' - searched in:", file=sys.stderr)
for subdir in manifest_subdirs:
print("\t" + subdir, file=sys.stderr)
print("Check specified release and current working " \
"directory (should be run from top-level of repo checkout).", file=sys.stderr)
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")