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

Side by Side Diff: releaseAutomation.py

Issue 5108575248580608: Issue 412 - Make sure release automation creates Safari builds (Closed)
Patch Set: Created May 2, 2014, 10:50 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-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 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, keyFiles, 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 metadata = packager.readMetadata(baseDir, type) 29 metadata = packager.readMetadata(baseDir, type)
30 with open(metadata.option_source("general", "version"), 'r+b') as file: 30 with open(metadata.option_source("general", "version"), 'r+b') as file:
31 rawMetadata = file.read() 31 rawMetadata = file.read()
(...skipping 17 matching lines...) Expand all
49 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaul tLocale]) 49 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaul tLocale])
50 extensionName = locales[packagerGecko.defaultLocale]['name'] 50 extensionName = locales[packagerGecko.defaultLocale]['name']
51 51
52 # Now commit the change and tag it 52 # Now commit the change and tag it
53 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)]) 53 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)])
54 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version]) 54 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version])
55 55
56 # Create a release build 56 # Create a release build
57 downloads = [] 57 downloads = []
58 if type == "gecko": 58 if type == "gecko":
59 keyFile = keyFiles[0] if keyFiles else None
59 metadata = packager.readMetadata(baseDir, type) 60 metadata = packager.readMetadata(baseDir, type)
60 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'xpi')) 61 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'xpi'))
61 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=Tru e, keyFile=keyFile) 62 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=Tru e, keyFile=keyFile)
62 downloads.append(buildPath) 63 downloads.append(buildPath)
63 elif type == "chrome": 64 elif type == "chrome":
64 # We actually have to create three different builds for Chrome: signed a uns igned Chrome builds 65 # We actually have to create four different builds for Chrome: signed a unsi gned Chrome builds
65 # (the latter for Chrome Web Store) and a signed Opera build. 66 # (the latter for Chrome Web Store), a signed Opera build and a signed Safar i build.
66 metadata = packager.readMetadata(baseDir, type) 67 metadata = packager.readMetadata(baseDir, type)
67 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'crx')) 68 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'crx'))
68 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=Tru e, keyFile=keyFile) 69 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=Tru e, keyFile=keyFiles[0])
69 downloads.append(buildPath) 70 downloads.append(buildPath)
70 71
71 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(baseDi r, metadata, version, 'zip')) 72 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(baseDi r, metadata, version, 'zip'))
72 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, releaseB uild=True, keyFile=None) 73 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, releaseB uild=True, keyFile=None)
73 74
74 metadataOpera = packager.readMetadata(baseDir, "opera") 75 metadataOpera = packager.readMetadata(baseDir, "opera")
75 buildPathOpera = os.path.join(downloadsRepo, packager.getDefaultFileName(bas eDir, metadataOpera, version, 'crx')) 76 buildPathOpera = os.path.join(downloadsRepo, packager.getDefaultFileName(bas eDir, metadataOpera, version, 'crx'))
76 packager.createBuild(baseDir, type="opera", outFile=buildPathOpera, releaseB uild=True, keyFile=keyFile) 77 packager.createBuild(baseDir, type="opera", outFile=buildPathOpera, releaseB uild=True, keyFile=keyFiles[0])
77 downloads.append(buildPathOpera) 78 downloads.append(buildPathOpera)
78 79
80 import buildtools.packagerSafari as packagerSafari
81 metadataSafari = packagerSafari.readMetadata(baseDir, "safari")
82 buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileN ame(baseDir, metadataSafari, version, 'safariextz'))
83 packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1])
84 downloads.append(buildPathSafari)
85
79 # Create source archive 86 # Create source archive
80 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' 87 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
81 88
82 archiveHandle = open(archivePath, 'wb') 89 archiveHandle = open(archivePath, 'wb')
83 archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePat h), mode='w:gz') 90 archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePat h), mode='w:gz')
84 data = subprocess.check_output(['hg', 'archive', '-R', baseDir, '-t', 'tar', ' -S', '-']) 91 data = subprocess.check_output(['hg', 'archive', '-R', baseDir, '-t', 'tar', ' -S', '-'])
85 repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:') 92 repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:')
86 for fileInfo in repoArchive: 93 for fileInfo in repoArchive:
87 if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'): 94 if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'):
88 continue 95 continue
89 fileData = repoArchive.extractfile(fileInfo) 96 fileData = repoArchive.extractfile(fileInfo)
90 fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name) 97 fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name)
91 archive.addfile(fileInfo, fileData) 98 archive.addfile(fileInfo, fileData)
92 repoArchive.close() 99 repoArchive.close()
93 archive.close() 100 archive.close()
94 archiveHandle.close() 101 archiveHandle.close()
95 downloads.append(archivePath) 102 downloads.append(archivePath)
96 103
97 # Now add the downloads and commit 104 # Now add the downloads and commit
98 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) 105 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
99 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)]) 106 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)])
100 107
101 # Push all changes 108 # Push all changes
102 subprocess.check_call(['hg', 'push', '-R', baseDir]) 109 subprocess.check_call(['hg', 'push', '-R', baseDir])
103 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 110 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