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

Side by Side Diff: releaseAutomation.py

Issue 29718566: Issue 6339 - Don't create encrypted archives on release Base URL: https://hg.adblockplus.org/buildtools/file/7ee9ad9b9390
Patch Set: Created March 9, 2018, 9:07 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 | « 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 # 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 from __future__ import print_function 5 from __future__ import print_function
6 6
7 import os 7 import os
8 import operator 8 import operator
9 import re 9 import re
10 import codecs 10 import codecs
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 rawMetadata = re.sub( 186 rawMetadata = re.sub(
187 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, 187 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version,
188 rawMetadata, flags=re.I | re.M 188 rawMetadata, flags=re.I | re.M
189 ) 189 )
190 190
191 fp.seek(0) 191 fp.seek(0)
192 fp.write(rawMetadata) 192 fp.write(rawMetadata)
193 fp.truncate() 193 fp.truncate()
194 194
195 195
196 def create_build(platform, base_dir, target_path, version, key_file=None): 196 def create_build(platform, base_dir, target_path, version):
197 """Create a build for the target platform and version.""" 197 """Create a build for the target platform and version."""
198 if platform == 'edge': 198 if platform == 'edge':
199 import buildtools.packagerEdge as packager 199 import buildtools.packagerEdge as packager
200 else: 200 else:
201 import buildtools.packagerChrome as packager 201 import buildtools.packagerChrome as packager
202 202
203 metadata = readMetadata(base_dir, platform) 203 metadata = readMetadata(base_dir, platform)
204 update_metadata(metadata, version) 204 update_metadata(metadata, version)
205 205
206 build_path = os.path.join( 206 build_path = os.path.join(
207 target_path, 207 target_path,
208 getDefaultFileName(metadata, version, 208 getDefaultFileName(metadata, version, get_extension(platform))
209 get_extension(platform, key_file is not None))
210 ) 209 )
211 210
212 packager.createBuild(base_dir, type=platform, outFile=build_path, 211 packager.createBuild(base_dir, type=platform, outFile=build_path,
213 releaseBuild=True, keyFile=key_file) 212 releaseBuild=True)
214 213
215 return build_path 214 return build_path
216 215
217 216
218 def release_commit(base_dir, extension_name, version, platforms): 217 def release_commit(base_dir, extension_name, version, platforms):
219 """Create a release commit with a representative message.""" 218 """Create a release commit with a representative message."""
220 subprocess.check_output([ 219 subprocess.check_output([
221 'hg', 'commit', '-R', base_dir, '-m', 220 'hg', 'commit', '-R', base_dir, '-m',
222 'Noissue - Releasing {} {} for {}'.format( 221 'Noissue - Releasing {} {} for {}'.format(
223 extension_name, version, 222 extension_name, version,
224 ', '.join([p.capitalize() for p in platforms]))], 223 ', '.join([p.capitalize() for p in platforms]))],
225 stderr=subprocess.STDOUT) 224 stderr=subprocess.STDOUT)
226 225
227 226
228 def release_tag(base_dir, tag_name, extension_name): 227 def release_tag(base_dir, tag_name, extension_name):
229 """Create a tag, along with a commit message for that tag.""" 228 """Create a tag, along with a commit message for that tag."""
230 subprocess.check_call([ 229 subprocess.check_call([
231 'hg', 'tag', '-R', base_dir, '-f', tag_name, 230 'hg', 'tag', '-R', base_dir, '-f', tag_name,
232 '-m', 'Noissue - Adding release tag for {} {}'.format( 231 '-m', 'Noissue - Adding release tag for {} {}'.format(
233 extension_name, tag_name)]) 232 extension_name, tag_name)])
234 233
235 234
236 def run(baseDir, platforms, version, keyFile, downloads_repo): 235 def run(baseDir, platforms, version, downloads_repo):
237 if not can_safely_release(baseDir, downloads_repo): 236 if not can_safely_release(baseDir, downloads_repo):
238 print('Aborting release.') 237 print('Aborting release.')
239 return 1 238 return 1
240 239
241 target_platforms = sorted(platforms) 240 target_platforms = sorted(platforms)
242 release_identifier = '-'.join([version] + [p for p in target_platforms]) 241 release_identifier = '-'.join([version] + [p for p in target_platforms])
243 242
244 release_possible, reason, re_release = release_combination_is_possible( 243 release_possible, reason, re_release = release_combination_is_possible(
245 version, platforms, baseDir) 244 version, platforms, baseDir)
246 245
247 if not release_possible: 246 if not release_possible:
248 logging.error(reason) 247 logging.error(reason)
249 return 2 248 return 2
250 249
251 downloads = [] 250 downloads = []
252 # Read extension name from first provided platform 251 # Read extension name from first provided platform
253 locale_config = read_locale_config( 252 locale_config = read_locale_config(
254 baseDir, target_platforms[0], 253 baseDir, target_platforms[0],
255 readMetadata(baseDir, target_platforms[0])) 254 readMetadata(baseDir, target_platforms[0]))
256 default_locale_path = os.path.join(locale_config['base_path'], 255 default_locale_path = os.path.join(locale_config['base_path'],
257 locale_config['default_locale'], 256 locale_config['default_locale'],
258 'messages.json') 257 'messages.json')
259 with open(default_locale_path, 'r') as fp: 258 with open(default_locale_path, 'r') as fp:
260 extension_name = json.load(fp)['name']['message'] 259 extension_name = json.load(fp)['name']['message']
261 260
262 for platform in target_platforms: 261 for platform in target_platforms:
263 used_key_file = None
264 if platform == 'chrome':
265 # Currently, only chrome builds are provided by us as signed
266 # packages. Create an unsigned package in base_dir which should be
267 # uploaded to the Chrome Web Store
268 create_build(platform, baseDir, baseDir, version)
269 used_key_file = keyFile
270
271 downloads.append( 262 downloads.append(
272 create_build(platform, baseDir, downloads_repo, version, 263 create_build(platform, baseDir, downloads_repo, version)
273 used_key_file)
274 ) 264 )
275 265
276 # Only create one commit, one tag and one source archive for all 266 # Only create one commit, one tag and one source archive for all
277 # platforms 267 # platforms
278 archive_path = os.path.join( 268 archive_path = os.path.join(
279 downloads_repo, 269 downloads_repo,
280 'adblockplus-{}-source.tgz'.format(release_identifier), 270 'adblockplus-{}-source.tgz'.format(release_identifier),
281 ) 271 )
282 create_sourcearchive(baseDir, archive_path) 272 create_sourcearchive(baseDir, archive_path)
283 downloads.append(archive_path) 273 downloads.append(archive_path)
284 try: 274 try:
285 release_commit(baseDir, extension_name, version, target_platforms) 275 release_commit(baseDir, extension_name, version, target_platforms)
286 except subprocess.CalledProcessError as e: 276 except subprocess.CalledProcessError as e:
287 if not (re_release and 'nothing changed' in e.output): 277 if not (re_release and 'nothing changed' in e.output):
288 raise 278 raise
289 279
290 release_tag(baseDir, release_identifier, extension_name) 280 release_tag(baseDir, release_identifier, extension_name)
291 281
292 # Now add the downloads and commit 282 # Now add the downloads and commit
293 subprocess.check_call(['hg', 'add', '-R', downloads_repo] + downloads) 283 subprocess.check_call(['hg', 'add', '-R', downloads_repo] + downloads)
294 release_commit(downloads_repo, extension_name, version, target_platforms) 284 release_commit(downloads_repo, extension_name, version, target_platforms)
295 285
296 # Push all changes 286 # Push all changes
297 subprocess.check_call(['hg', 'push', '-R', baseDir]) 287 subprocess.check_call(['hg', 'push', '-R', baseDir])
298 subprocess.check_call(['hg', 'push', '-R', downloads_repo]) 288 subprocess.check_call(['hg', 'push', '-R', downloads_repo])
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