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

Side by Side Diff: releaseAutomation.py

Issue 29357701: Issue 4548 - Split out Safari and add Edge release automation (Closed)
Patch Set: Avoid linting errors Created Oct. 26, 2016, 3:16 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 | « packagerEdge.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 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 import os 5 import os
6 import re 6 import re
7 import codecs 7 import codecs
8 import subprocess 8 import subprocess
9 import tarfile 9 import tarfile
10 import json 10 import json
(...skipping 25 matching lines...) Expand all
36 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgig nore'): 36 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgig nore'):
37 continue 37 continue
38 filedata = repoarchive.extractfile(fileinfo) 38 filedata = repoarchive.extractfile(fileinfo)
39 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name ) 39 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name )
40 archive.addfile(fileinfo, filedata) 40 archive.addfile(fileinfo, filedata)
41 finally: 41 finally:
42 process.stdout.close() 42 process.stdout.close()
43 process.wait() 43 process.wait()
44 44
45 45
46 def run(baseDir, type, version, keyFiles, downloadsRepo): 46 def run(baseDir, type, version, keyFile, downloadsRepo):
47 if type == 'gecko': 47 if type == 'gecko':
48 import buildtools.packagerGecko as packager 48 import buildtools.packagerGecko as packager
49 elif type == 'safari':
50 import buildtools.packagerSafari as packager
51 elif type == 'edge':
52 import buildtools.packagerEdge as packager
49 elif type == 'chrome': 53 elif type == 'chrome':
50 import buildtools.packagerChrome as packager 54 import buildtools.packagerChrome as packager
51 55
52 # Replace version number in metadata file "manually", ConfigParser will mess 56 # Replace version number in metadata file "manually", ConfigParser will mess
53 # up the order of lines. 57 # up the order of lines.
54 metadata = packager.readMetadata(baseDir, type) 58 metadata = packager.readMetadata(baseDir, type)
55 with open(metadata.option_source('general', 'version'), 'r+b') as file: 59 with open(metadata.option_source('general', 'version'), 'r+b') as file:
56 rawMetadata = file.read() 60 rawMetadata = file.read()
57 rawMetadata = re.sub( 61 rawMetadata = re.sub(
58 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, 62 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version,
(...skipping 10 matching lines...) Expand all
69 locales_base = baseDir 73 locales_base = baseDir
70 else: 74 else:
71 # This is somewhat of a hack but reading out locale import config here w ould be too much 75 # This is somewhat of a hack but reading out locale import config here w ould be too much
72 locales_base = os.path.join(baseDir, 'adblockplus') 76 locales_base = os.path.join(baseDir, 'adblockplus')
73 77
74 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale]) 78 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale])
75 extensionName = locales[packagerGecko.defaultLocale]['name'] 79 extensionName = locales[packagerGecko.defaultLocale]['name']
76 80
77 # Now commit the change and tag it 81 # Now commit the change and tag it
78 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)]) 82 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)])
79 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version]) 83 tag_name = version
84 if type in {'safari', 'edge'}:
85 tag_name += '-' + type
Sebastian Noack 2016/10/27 10:57:32 Nit: As per our coding style, we use the format()
kzar 2016/10/27 15:25:58 Do you insist? IMO `tag_name += '-' + type` is nic
Sebastian Noack 2016/10/27 15:41:59 This might be a matter of taste. I think the strin
kzar 2016/10/27 15:54:25 Done.
86 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name])
80 87
81 # Create a release build 88 # Create a release build
82 downloads = [] 89 downloads = []
83 if type == 'gecko': 90 if type == 'gecko':
84 keyFile = keyFiles[0] if keyFiles else None
85 metadata = packager.readMetadata(baseDir, type)
86 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'xpi')) 91 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'xpi'))
87 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) 92 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True)
88 downloads.append(buildPath) 93 downloads.append(buildPath)
89 elif type == 'chrome': 94 elif type == 'chrome':
90 # We actually have to create three different builds: signed and unsigned 95 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store).
91 # Chrome builds (the latter for Chrome Web Store), and a signed Safari b uild.
92 metadata = packager.readMetadata(baseDir, type)
93 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'crx')) 96 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'crx'))
94 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFiles[0]) 97 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile)
95 downloads.append(buildPath) 98 downloads.append(buildPath)
96 99
97 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(me tadata, version, 'zip')) 100 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(me tadata, version, 'zip'))
98 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) 101 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None)
99 102 elif type == 'safari':
100 import buildtools.packagerSafari as packagerSafari 103 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'safariextz'))
101 metadataSafari = packagerSafari.readMetadata(baseDir, 'safari') 104 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile)
102 buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultF ileName(metadataSafari, version, 'safariextz')) 105 downloads.append(buildPath)
103 packagerSafari.createBuild(baseDir, type='safari', outFile=buildPathSafa ri, releaseBuild=True, keyFile=keyFiles[1]) 106 elif type == 'edge':
104 downloads.append(buildPathSafari) 107 # We only offer the Edge extension for use through the Windows Store
108 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'appx'))
109 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True)
110 downloads.append(buildPath)
105 111
106 # Create source archive 112 # Create source archive
107 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' 113 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
108 create_sourcearchive(baseDir, archivePath) 114 create_sourcearchive(baseDir, archivePath)
109 downloads.append(archivePath) 115 downloads.append(archivePath)
110 116
111 # Now add the downloads and commit 117 # Now add the downloads and commit
112 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) 118 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
113 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) 119 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)])
114 120
115 # Push all changes 121 # Push all changes
116 subprocess.check_call(['hg', 'push', '-R', baseDir]) 122 subprocess.check_call(['hg', 'push', '-R', baseDir])
117 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 123 subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
OLDNEW
« no previous file with comments | « packagerEdge.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld