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

Side by Side Diff: releaseAutomation.py

Issue 11586054: Add Chrome release automation (Closed)
Patch Set: Created Sept. 2, 2013, 9:06 a.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 | « build.py ('k') | 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, subprocess, tarfile 18 import os, re, codecs, subprocess, tarfile, json
19 from StringIO import StringIO 19 from StringIO import StringIO
20 import buildtools.packagerGecko as packager
21 20
22 def run(baseDir, type, version, keyFile, downloadsRepo): 21 def run(baseDir, type, version, keyFile, downloadsRepo):
22 if type == "gecko":
23 import buildtools.packagerGecko as packager
24 elif type == "chrome":
25 import buildtools.packagerChrome as packager
26
23 # Replace version number in metadata file "manually", ConfigParser will mess 27 # Replace version number in metadata file "manually", ConfigParser will mess
24 # up the order of lines. 28 # up the order of lines.
25 handle = open(packager.getMetadataPath(baseDir, type), 'rb') 29 handle = open(packager.getMetadataPath(baseDir, type), 'rb')
26 rawMetadata = handle.read() 30 rawMetadata = handle.read()
27 handle.close() 31 handle.close()
28 versionRegExp = re.compile(r'^(\s*version\s*=\s*).*', re.I | re.M) 32 versionRegExp = re.compile(r'^(\s*version\s*=\s*).*', re.I | re.M)
29 rawMetadata = re.sub(versionRegExp, r'\g<1>%s' % version, rawMetadata) 33 rawMetadata = re.sub(versionRegExp, r'\g<1>%s' % version, rawMetadata)
30 handle = open(packager.getMetadataPath(baseDir, type), 'wb') 34 handle = open(packager.getMetadataPath(baseDir, type), 'wb')
31 handle.write(rawMetadata) 35 handle.write(rawMetadata)
32 handle.close() 36 handle.close()
33 37
34 # Read extension name and branch name 38 # Read extension name from locale data
35 locales = packager.readLocaleMetadata(baseDir, [packager.defaultLocale]) 39 import buildtools.packagerGecko as packagerGecko
36 extensionName = locales[packager.defaultLocale]['name'] 40 if type == "gecko":
41 locales_base = baseDir
42 else:
43 # 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")
37 45
38 metadata = packager.readMetadata(baseDir, type) 46 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaul tLocale])
47 extensionName = locales[packagerGecko.defaultLocale]['name']
39 48
40 # Now commit the change and tag it 49 # Now commit the change and tag it
41 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)]) 50 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)])
42 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version]) 51 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version])
43 52
44 # Create a release build 53 # Create a release build
45 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, m etadata, version, 'xpi')) 54 downloads = []
46 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=True, keyFile=keyFile) 55 if type == "gecko":
56 metadata = packager.readMetadata(baseDir, type)
57 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'xpi'))
58 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=Tru e, keyFile=keyFile)
59 downloads.append(buildPath)
60 elif type == "chrome":
61 # We actually have to create three different builds for Chrome: signed a uns igned Chrome builds
62 # (the latter for Chrome Web Store) and a signed Opera build.
63 metadata = packager.readMetadata(baseDir, type)
64 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'crx'))
65 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=Tru e, keyFile=keyFile)
66 downloads.append(buildPath)
67
68 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(baseDi r, metadata, version, 'zip'))
69 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, releaseB uild=True, keyFile=None)
70
71 metadataOpera = packager.readMetadata(baseDir, "opera")
72 buildPathOpera = os.path.join(downloadsRepo, packager.getDefaultFileName(bas eDir, metadataOpera, version, 'crx'))
73 packager.createBuild(baseDir, type="opera", outFile=buildPathOpera, releaseB uild=True, keyFile=keyFile)
74 downloads.append(buildPathOpera)
47 75
48 # Create source archive 76 # Create source archive
49 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' 77 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
50 78
51 archiveHandle = open(archivePath, 'wb') 79 archiveHandle = open(archivePath, 'wb')
52 archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePat h), mode='w:gz') 80 archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePat h), mode='w:gz')
53 data = subprocess.check_output(['hg', 'archive', '-R', baseDir, '-t', 'tar', ' -S', '-']) 81 data = subprocess.check_output(['hg', 'archive', '-R', baseDir, '-t', 'tar', ' -S', '-'])
54 repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:') 82 repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:')
55 for fileInfo in repoArchive: 83 for fileInfo in repoArchive:
56 if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'): 84 if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'):
57 continue 85 continue
58 fileData = repoArchive.extractfile(fileInfo) 86 fileData = repoArchive.extractfile(fileInfo)
59 fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name) 87 fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name)
60 archive.addfile(fileInfo, fileData) 88 archive.addfile(fileInfo, fileData)
61 repoArchive.close() 89 repoArchive.close()
62 archive.close() 90 archive.close()
63 archiveHandle.close() 91 archiveHandle.close()
92 downloads.append(archivePath)
64 93
65 # Now add the downloads and commit 94 # Now add the downloads and commit
66 subprocess.check_call(['hg', 'add', '-R', downloadsRepo, buildPath, archivePat h]) 95 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
67 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)]) 96 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)])
68 97
69 # Push all changes 98 # Push all changes
70 subprocess.check_call(['hg', 'push', '-R', baseDir]) 99 subprocess.check_call(['hg', 'push', '-R', baseDir])
71 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 100 subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
OLDNEW
« no previous file with comments | « build.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld