Left: | ||
Right: |
OLD | NEW |
---|---|
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 re | 8 import re |
9 import codecs | 9 import codecs |
10 import subprocess | 10 import subprocess |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 if repo_has_outgoing(): | 111 if repo_has_outgoing(): |
112 return continue_with_outgoing() | 112 return continue_with_outgoing() |
113 return True | 113 return True |
114 | 114 |
115 | 115 |
116 def run(baseDir, type, version, keyFile, downloadsRepo): | 116 def run(baseDir, type, version, keyFile, downloadsRepo): |
117 if not can_safely_release(baseDir, downloadsRepo): | 117 if not can_safely_release(baseDir, downloadsRepo): |
118 print('Aborting release.') | 118 print('Aborting release.') |
119 return 1 | 119 return 1 |
120 | 120 |
121 if type == 'gecko': | 121 if type == 'safari': |
122 import buildtools.packagerGecko as packager | |
123 elif type == 'safari': | |
124 import buildtools.packagerSafari as packager | 122 import buildtools.packagerSafari as packager |
125 elif type == 'edge': | 123 elif type == 'edge': |
126 import buildtools.packagerEdge as packager | 124 import buildtools.packagerEdge as packager |
127 elif type == 'chrome': | 125 elif type == 'chrome': |
128 import buildtools.packagerChrome as packager | 126 import buildtools.packagerChrome as packager |
129 | 127 |
130 # Replace version number in metadata file "manually", ConfigParser will mess | 128 # Replace version number in metadata file "manually", ConfigParser will mess |
131 # up the order of lines. | 129 # up the order of lines. |
132 metadata = readMetadata(baseDir, type) | 130 metadata = readMetadata(baseDir, type) |
133 with open(metadata.option_source('general', 'version'), 'r+b') as file: | 131 with open(metadata.option_source('general', 'version'), 'r+b') as file: |
134 rawMetadata = file.read() | 132 rawMetadata = file.read() |
135 rawMetadata = re.sub( | 133 rawMetadata = re.sub( |
136 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, | 134 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, |
137 rawMetadata, flags=re.I | re.M | 135 rawMetadata, flags=re.I | re.M |
138 ) | 136 ) |
139 | 137 |
140 file.seek(0) | 138 file.seek(0) |
141 file.write(rawMetadata) | 139 file.write(rawMetadata) |
142 file.truncate() | 140 file.truncate() |
143 | 141 |
144 # Read extension name from locale data | 142 # Read extension name from locale data |
145 import buildtools.packagerGecko as packagerGecko | 143 locales_base = os.path.join(baseDir, 'adblockplus') |
146 if type == 'gecko': | |
147 locales_base = baseDir | |
148 else: | |
149 # This is somewhat of a hack but reading out locale import config here w ould be too much | |
150 locales_base = os.path.join(baseDir, 'adblockplus') | |
151 | 144 |
152 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale]) | 145 with open(os.path.join(locales_base, 'chrome', 'locale', |
Sebastian Noack
2017/10/04 22:22:18
This will no longer work since the "adblockplus" d
tlucas
2017/10/05 10:10:30
Done.
| |
153 extensionName = locales[packagerGecko.defaultLocale]['name'] | 146 packager.defaultLocale.replace('_', '-'), |
147 'meta.json'), | |
148 'r') as fp: | |
149 extensionName = json.load(fp)['name'] | |
154 | 150 |
155 # Now commit the change and tag it | 151 # Now commit the change and tag it |
156 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)]) | 152 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)]) |
157 tag_name = version | 153 tag_name = version |
158 if type in {'safari', 'edge'}: | 154 if type in {'safari', 'edge'}: |
159 tag_name = '{}-{}'.format(tag_name, type) | 155 tag_name = '{}-{}'.format(tag_name, type) |
160 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) | 156 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) |
161 | 157 |
162 # Create a release build | 158 # Create a release build |
163 downloads = [] | 159 downloads = [] |
164 if type == 'gecko': | 160 if type == 'chrome': |
165 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'xpi')) | |
166 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) | |
167 downloads.append(buildPath) | |
168 elif type == 'chrome': | |
169 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store). | 161 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store). |
170 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'crx')) | 162 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'crx')) |
171 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) | 163 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) |
172 downloads.append(buildPath) | 164 downloads.append(buildPath) |
173 | 165 |
174 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v ersion, 'zip')) | 166 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v ersion, 'zip')) |
175 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) | 167 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) |
176 elif type == 'safari': | 168 elif type == 'safari': |
177 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'safariextz')) | 169 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'safariextz')) |
178 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) | 170 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) |
179 downloads.append(buildPath) | 171 downloads.append(buildPath) |
180 elif type == 'edge': | 172 elif type == 'edge': |
181 # We only offer the Edge extension for use through the Windows Store | 173 # We only offer the Edge extension for use through the Windows Store |
182 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'appx')) | 174 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'appx')) |
183 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) | 175 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) |
184 downloads.append(buildPath) | 176 downloads.append(buildPath) |
185 | 177 |
186 # Create source archive | 178 # Create source archive |
187 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 179 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
188 create_sourcearchive(baseDir, archivePath) | 180 create_sourcearchive(baseDir, archivePath) |
189 downloads.append(archivePath) | 181 downloads.append(archivePath) |
190 | 182 |
191 # Now add the downloads and commit | 183 # Now add the downloads and commit |
192 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 184 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
193 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) | 185 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) |
194 | 186 |
195 # Push all changes | 187 # Push all changes |
196 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 188 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
197 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 189 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
OLD | NEW |