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

Delta Between Two Patch Sets: releaseAutomation.py

Issue 29357701: Issue 4548 - Split out Safari and add Edge release automation (Closed)
Left Patch Set: Addressed nits Created Oct. 25, 2016, 10:35 a.m.
Right Patch Set: Addressed nits Created Oct. 27, 2016, 3:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « packagerEdge.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 11
12 from packager import readMetadata, getDefaultFileName
12 13
13 def get_dependencies(prefix, repos): 14 def get_dependencies(prefix, repos):
14 from ensure_dependencies import read_deps, safe_join 15 from ensure_dependencies import read_deps, safe_join
15 repo = repos[prefix] 16 repo = repos[prefix]
16 deps = read_deps(repo) 17 deps = read_deps(repo)
17 if deps: 18 if deps:
18 for subpath in deps: 19 for subpath in deps:
19 if subpath.startswith('_'): 20 if subpath.startswith('_'):
20 continue 21 continue
21 depprefix = prefix + subpath + '/' 22 depprefix = prefix + subpath + '/'
(...skipping 26 matching lines...) Expand all
48 import buildtools.packagerGecko as packager 49 import buildtools.packagerGecko as packager
49 elif type == 'safari': 50 elif type == 'safari':
50 import buildtools.packagerSafari as packager 51 import buildtools.packagerSafari as packager
51 elif type == 'edge': 52 elif type == 'edge':
52 import buildtools.packagerEdge as packager 53 import buildtools.packagerEdge as packager
53 elif type == 'chrome': 54 elif type == 'chrome':
54 import buildtools.packagerChrome as packager 55 import buildtools.packagerChrome as packager
55 56
56 # Replace version number in metadata file "manually", ConfigParser will mess 57 # Replace version number in metadata file "manually", ConfigParser will mess
57 # up the order of lines. 58 # up the order of lines.
58 metadata = packager.readMetadata(baseDir, type) 59 metadata = readMetadata(baseDir, type)
59 with open(metadata.option_source('general', 'version'), 'r+b') as file: 60 with open(metadata.option_source('general', 'version'), 'r+b') as file:
60 rawMetadata = file.read() 61 rawMetadata = file.read()
61 rawMetadata = re.sub( 62 rawMetadata = re.sub(
62 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, 63 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version,
63 rawMetadata, flags=re.I | re.M 64 rawMetadata, flags=re.I | re.M
64 ) 65 )
65 66
66 file.seek(0) 67 file.seek(0)
67 file.write(rawMetadata) 68 file.write(rawMetadata)
68 file.truncate() 69 file.truncate()
69 70
70 # Read extension name from locale data 71 # Read extension name from locale data
71 import buildtools.packagerGecko as packagerGecko 72 import buildtools.packagerGecko as packagerGecko
72 if type == 'gecko': 73 if type == 'gecko':
73 locales_base = baseDir 74 locales_base = baseDir
74 else: 75 else:
75 # This is somewhat of a hack but reading out locale import config here w ould be too much 76 # This is somewhat of a hack but reading out locale import config here w ould be too much
76 locales_base = os.path.join(baseDir, 'adblockplus') 77 locales_base = os.path.join(baseDir, 'adblockplus')
77 78
78 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale]) 79 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale])
79 extensionName = locales[packagerGecko.defaultLocale]['name'] 80 extensionName = locales[packagerGecko.defaultLocale]['name']
80 81
81 # Now commit the change and tag it 82 # Now commit the change and tag it
82 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)]) 83 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)])
83 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version]) 84 tag_name = version
85 if type in {'safari', 'edge'}:
86 tag_name = '{}-{}'.format(tag_name, type)
87 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name])
84 88
85 # Create a release build 89 # Create a release build
86 downloads = [] 90 downloads = []
87 if type == 'gecko': 91 if type == 'gecko':
88 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'xpi')) 92 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'xpi'))
89 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) 93 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True)
90 downloads.append(buildPath) 94 downloads.append(buildPath)
91 elif type == 'chrome': 95 elif type == 'chrome':
92 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store). 96 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store).
93 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'crx')) 97 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'crx'))
94 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) 98 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile)
95 downloads.append(buildPath) 99 downloads.append(buildPath)
96 100
97 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(me tadata, version, 'zip')) 101 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v ersion, 'zip'))
98 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) 102 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None)
99 elif type == 'safari': 103 elif type == 'safari':
100 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'safariextz')) 104 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'safariextz'))
101 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) 105 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile)
102 downloads.append(buildPath) 106 downloads.append(buildPath)
103 elif type == 'edge': 107 elif type == 'edge':
104 # We only offer the Edge extension for use through the Windows Store 108 # We only offer the Edge extension for use through the Windows Store
105 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'appx')) 109 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'appx'))
106 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) 110 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True)
107 downloads.append(buildPath) 111 downloads.append(buildPath)
108 112
109 # Create source archive 113 # Create source archive
110 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' 114 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
111 create_sourcearchive(baseDir, archivePath) 115 create_sourcearchive(baseDir, archivePath)
112 downloads.append(archivePath) 116 downloads.append(archivePath)
113 117
114 # Now add the downloads and commit 118 # Now add the downloads and commit
115 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) 119 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
116 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) 120 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)])
117 121
118 # Push all changes 122 # Push all changes
119 subprocess.check_call(['hg', 'push', '-R', baseDir]) 123 subprocess.check_call(['hg', 'push', '-R', baseDir])
120 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 124 subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
LEFTRIGHT

Powered by Google App Engine
This is Rietveld