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

Subscribers

People subscribed via source and target branches

to all changes: