| 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 default_locale_path = os.path.join('_locales', packager.defaultLocale, |
| 146 if type == 'gecko': | 144 'messages.json') |
| 147 locales_base = baseDir | 145 with open(default_locale_path, 'r') as fp: |
| 148 else: | 146 extensionName = json.load(fp)['name'] |
| 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 | |
| 152 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa
ultLocale]) | |
| 153 extensionName = locales[packagerGecko.defaultLocale]['name'] | |
| 154 | 147 |
| 155 # Now commit the change and tag it | 148 # Now commit the change and tag it |
| 156 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) | 149 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) |
| 157 tag_name = version | 150 tag_name = version |
| 158 if type in {'safari', 'edge'}: | 151 if type in {'safari', 'edge'}: |
| 159 tag_name = '{}-{}'.format(tag_name, type) | 152 tag_name = '{}-{}'.format(tag_name, type) |
| 160 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) | 153 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) |
| 161 | 154 |
| 162 # Create a release build | 155 # Create a release build |
| 163 downloads = [] | 156 downloads = [] |
| 164 if type == 'gecko': | 157 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). | 158 # 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')) | 159 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'crx')) |
| 171 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) | 160 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) |
| 172 downloads.append(buildPath) | 161 downloads.append(buildPath) |
| 173 | 162 |
| 174 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v
ersion, 'zip')) | 163 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v
ersion, 'zip')) |
| 175 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) | 164 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) |
| 176 elif type == 'safari': | 165 elif type == 'safari': |
| 177 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'safariextz')) | 166 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'safariextz')) |
| 178 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB
uild=True, keyFile=keyFile) | 167 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB
uild=True, keyFile=keyFile) |
| 179 downloads.append(buildPath) | 168 downloads.append(buildPath) |
| 180 elif type == 'edge': | 169 elif type == 'edge': |
| 181 # We only offer the Edge extension for use through the Windows Store | 170 # We only offer the Edge extension for use through the Windows Store |
| 182 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'appx')) | 171 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'appx')) |
| 183 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) | 172 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) |
| 184 downloads.append(buildPath) | 173 downloads.append(buildPath) |
| 185 | 174 |
| 186 # Create source archive | 175 # Create source archive |
| 187 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 176 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
| 188 create_sourcearchive(baseDir, archivePath) | 177 create_sourcearchive(baseDir, archivePath) |
| 189 downloads.append(archivePath) | 178 downloads.append(archivePath) |
| 190 | 179 |
| 191 # Now add the downloads and commit | 180 # Now add the downloads and commit |
| 192 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 181 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
| 193 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) | 182 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) |
| 194 | 183 |
| 195 # Push all changes | 184 # Push all changes |
| 196 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 185 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
| 197 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 186 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
| OLD | NEW |