Merge lp:~compiz-team/compiz/compiz.add-release-script into lp:compiz/0.9.10

Proposed by Sam Spilsbury
Status: Merged
Approved by: MC Return
Approved revision: 3754
Merged at revision: 3754
Proposed branch: lp:~compiz-team/compiz/compiz.add-release-script
Merge into: lp:compiz/0.9.10
Diff against target: 209 lines (+205/-0)
1 file modified
scripts/release.py (+205/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.add-release-script
Reviewer Review Type Date Requested Status
MC Return Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+173364@code.launchpad.net

Commit message

Add a simple script for making releases

Description of the change

Add a simple script for making releases

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote :

Great! +1
LGTM, AFAICT.

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

Andyrock just told me that I should feel free to unblock trunk, so this should land first.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'scripts/release.py'
2--- scripts/release.py 1970-01-01 00:00:00 +0000
3+++ scripts/release.py 2013-07-07 19:22:25 +0000
4@@ -0,0 +1,205 @@
5+#!/usr/env/python
6+# Usage: release.py VERSION. Creates a new compiz release and bumps VERSION
7+# to the next release
8+#
9+# Copyright (c) Sam Spilsbury <smspillaz@gmail.com>
10+#
11+# This program is free software; you can redistribute it and/or modify
12+# it under the terms of the GNU General Public License as published by
13+# the Free Software Foundation; either version 2 of the License, or
14+# (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU General Public License for more details.
20+#
21+# You should have received a copy of the GNU General Public License
22+# along with this program; if not, write to the Free Software
23+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24+import sys
25+import os
26+import bzrlib.branch
27+import bzrlib.workingtree
28+import bzrlib.errors as errors
29+from launchpadlib.launchpad import Launchpad
30+import datetime
31+
32+def usage ():
33+ print ("release.py VERSION")
34+ print ("Make a release and bump version to VERSION")
35+ sys.exit (1)
36+
37+if len(sys.argv) != 2:
38+ usage ()
39+
40+if not "release.py" in os.listdir ("."):
41+ print ("Working directory must contain this script")
42+ sys.exit (1)
43+
44+editor = ""
45+
46+try:
47+ editor = os.environ["EDITOR"]
48+except KeyError:
49+ print ("EDITOR must be set")
50+ sys.exit (1)
51+
52+if len (editor) == 0:
53+ print ("EDITOR must be set")
54+ sys.exit (1)
55+
56+bzrlib.initialize ()
57+compiz_branch = bzrlib.branch.Branch.open ("..")
58+compiz_branch.lock_read ()
59+tags = compiz_branch.tags.get_tag_dict ().items ()
60+
61+most_recent_revision = 0
62+
63+# Find the last tagged revision
64+for tag, revid in tags:
65+ try:
66+ revision = compiz_branch.revision_id_to_dotted_revno (revid)[0]
67+
68+ if int (revision) > most_recent_revision:
69+ most_recent_revision = revision
70+ except (errors.NoSuchRevision,
71+ errors.GhostRevisionsHaveNoRevno,
72+ errors.UnsupportedOperation):
73+ pass
74+
75+repo = compiz_branch.repository
76+release_revisions = []
77+
78+# Find all revisions since that one
79+for revision_id in repo.get_revisions (repo.all_revision_ids ()):
80+ try:
81+ revno = compiz_branch.revision_id_to_dotted_revno (revision_id.revision_id)[0]
82+
83+ if revno > most_recent_revision:
84+ release_revisions.append (revision_id)
85+
86+ except (errors.NoSuchRevision,
87+ errors.GhostRevisionsHaveNoRevno,
88+ errors.UnsupportedOperation):
89+ pass
90+
91+# Find all fixed bugs in those revisions
92+bugs = []
93+
94+for rev in release_revisions:
95+ for bug in rev.iter_bugs():
96+ bugs.append (bug[0][27:])
97+
98+bugs = sorted (bugs)
99+
100+# Connect to launchpad
101+lp = Launchpad.login_anonymously ("Compiz Release Script", "production")
102+
103+# Create a pretty looking formatted list of bugs
104+bugs_formatted = []
105+
106+for bug in bugs:
107+ lpBug = lp.bugs[bug]
108+ bugTitle = lpBug.title
109+
110+ bugTitleWords = bugTitle.split (" ")
111+ maximumLineLength = 65
112+ currentLineLength = 0
113+ line = 0
114+ lineParts = [""]
115+
116+ for word in bugTitleWords:
117+ wordLength = len (word) + 1
118+ if wordLength + currentLineLength > maximumLineLength:
119+ lineParts.append ("")
120+ line = line + 1
121+ currentLineLength = 0
122+ elif currentLineLength != 0:
123+ lineParts[line] += " "
124+
125+ currentLineLength += wordLength
126+ lineParts[line] += (word)
127+
128+ bugs_formatted.append ((bug, lineParts))
129+
130+# Pretty-print the bugs
131+bugs_formatted_msg = ""
132+
133+for bug, lines in bugs_formatted:
134+ whitespace = " " * (12 - len (bug))
135+ bugs_formatted_msg += whitespace + bug + " - " + lines[0] + "\n"
136+
137+ if len (lines) > 1:
138+ for i in range (1, len (lines)):
139+ whitespace = " " * 15
140+ bugs_formatted_msg += whitespace + lines[i] + "\n"
141+
142+# Get the version
143+version_file = open ("../VERSION", "r")
144+version = version_file.readlines ()[0][:-1]
145+version_file.close ()
146+
147+# Get the date
148+date = datetime.datetime.now ()
149+date_formatted = str(date.year) + "-" + str(date.month) + "-" + str(date.day)
150+
151+# Create release message
152+release_msg = "Release " + version + " (" + date_formatted + " NAME <EMAIL>)\n"
153+release_msg += "=" * 77 + "\n\n"
154+release_msg += "Highlights\n\n"
155+release_msg += "Bugs Fixed (https://launchpad.net/compiz/+milestone/" + version + ")\n\n"
156+release_msg += bugs_formatted_msg
157+
158+print release_msg
159+
160+# Edit release message
161+news_update_file = open (".release-script-" + version, "w+")
162+news_update_file.write (release_msg.encode ("utf8"))
163+news_update_file.close ()
164+
165+os.system (editor + " .release-script-" + version)
166+
167+# Open NEWS
168+news_file = open ("../NEWS", "r")
169+news_lines = news_file.readlines ()
170+news_prepend_file = open (".release-script-" + version, "r")
171+news_prepend_lines = news_prepend_file.readlines ()
172+
173+for i in range (0, len (news_prepend_lines)):
174+ news_prepend_lines[i] = news_prepend_lines[i].decode ("utf8")
175+
176+news_prepend_lines.append ("\n")
177+
178+for line in news_lines:
179+ news_prepend_lines.append (line.decode ("utf8"))
180+
181+news = ""
182+
183+for line in news_prepend_lines:
184+ news += line
185+
186+news_file.close ()
187+news_prepend_file.close ()
188+news_file = open ("../NEWS", "w")
189+news_file.write (news.encode ("utf8"))
190+news_file.close ()
191+
192+# Commit
193+compiz_tree = bzrlib.workingtree.WorkingTree.open ("..")
194+compiz_tree.commit ("Release version " + version)
195+
196+# Create a tag
197+compiz_branch.unlock ()
198+compiz_branch.lock_write ()
199+compiz_branch.tags.set_tag ("v" + version, compiz_branch.last_revision ())
200+compiz_branch.unlock ()
201+
202+# Update version
203+version_file = open ("../VERSION", "w")
204+version_file.write (sys.argv[1] + "\n")
205+version_file.close ()
206+
207+# Commit
208+compiz_tree = bzrlib.workingtree.WorkingTree.open ("..")
209+compiz_tree.commit ("Bump VERSION to " + sys.argv[1])

Subscribers

People subscribed via source and target branches

to all changes: