Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: releaseAutomation.py

Issue 6047895316856832: Rewrite version number in the correct file during release automation (Closed)
Patch Set: Adressed comments Created Jan. 15, 2014, 4 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus build tools, 3 # This file is part of the Adblock Plus build tools,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import os, re, codecs, subprocess, tarfile, json 18 import os, re, codecs, subprocess, tarfile, json
19 from StringIO import StringIO 19 from StringIO import StringIO
20 20
21 def run(baseDir, type, version, keyFile, downloadsRepo): 21 def run(baseDir, type, version, keyFile, downloadsRepo):
22 if type == "gecko": 22 if type == "gecko":
23 import buildtools.packagerGecko as packager 23 import buildtools.packagerGecko as packager
24 elif type == "chrome": 24 elif type == "chrome":
25 import buildtools.packagerChrome as packager 25 import buildtools.packagerChrome as packager
26 26
27 # Replace version number in metadata file "manually", ConfigParser will mess 27 # Replace version number in metadata file "manually", ConfigParser will mess
28 # up the order of lines. 28 # up the order of lines.
29 handle = open(packager.getMetadataPath(baseDir, type), 'rb') 29 metadata = packager.readMetadata(baseDir, type)
30 rawMetadata = handle.read() 30 with open(metadata.option_source("general", "version"), 'r+b') as file:
31 handle.close() 31 rawMetadata = file.read()
32 versionRegExp = re.compile(r'^(\s*version\s*=\s*).*', re.I | re.M) 32 rawMetadata = re.sub(
33 rawMetadata = re.sub(versionRegExp, r'\g<1>%s' % version, rawMetadata) 33 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version,
34 handle = open(packager.getMetadataPath(baseDir, type), 'wb') 34 rawMetadata, flags=re.I | re.M
35 handle.write(rawMetadata) 35 )
36 handle.close() 36
37 file.seek(0)
38 file.write(rawMetadata)
39 file.truncate()
37 40
38 # Read extension name from locale data 41 # Read extension name from locale data
39 import buildtools.packagerGecko as packagerGecko 42 import buildtools.packagerGecko as packagerGecko
40 if type == "gecko": 43 if type == "gecko":
41 locales_base = baseDir 44 locales_base = baseDir
42 else: 45 else:
43 # This is somewhat of a hack but reading out locale import config here would be too much 46 # This is somewhat of a hack but reading out locale import config here would be too much
44 locales_base = os.path.join(baseDir, "adblockplus") 47 locales_base = os.path.join(baseDir, "adblockplus")
45 48
46 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaul tLocale]) 49 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaul tLocale])
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 archiveHandle.close() 94 archiveHandle.close()
92 downloads.append(archivePath) 95 downloads.append(archivePath)
93 96
94 # Now add the downloads and commit 97 # Now add the downloads and commit
95 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) 98 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
96 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)]) 99 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)])
97 100
98 # Push all changes 101 # Push all changes
99 subprocess.check_call(['hg', 'push', '-R', baseDir]) 102 subprocess.check_call(['hg', 'push', '-R', baseDir])
100 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 103 subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld