| 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 |
| 11 import tarfile | 11 import tarfile |
| 12 import json | 12 import json |
| 13 | 13 |
| 14 from packager import readMetadata, getDefaultFileName | 14 from packager import readMetadata, getDefaultFileName |
| 15 | 15 |
| 16 | 16 |
| 17 def get_dependencies(prefix, repos): | 17 def get_dependencies(prefix, repos): |
| 18 from ensure_dependencies import read_deps, safe_join | 18 from ensure_dependencies import read_deps, safe_join |
| 19 repo = repos[prefix] | 19 repo = repos[prefix] |
| 20 deps = read_deps(repo) | 20 deps = read_deps(repo) |
| 21 if deps: | 21 if deps: |
| 22 for subpath in deps: | 22 for subpath in deps: |
| 23 if subpath.startswith('_'): | 23 if subpath.startswith('_'): |
| 24 continue | 24 continue |
| 25 depprefix = prefix + subpath + '/' | 25 depprefix = prefix + subpath + '/' |
| (...skipping 85 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 == 'safari': | 121 if type == 'edge': |
| 122 import buildtools.packagerSafari as packager | |
| 123 elif type == 'edge': | |
| 124 import buildtools.packagerEdge as packager | 122 import buildtools.packagerEdge as packager |
| 125 elif type == 'chrome': | 123 elif type == 'chrome': |
| 126 import buildtools.packagerChrome as packager | 124 import buildtools.packagerChrome as packager |
| 127 | 125 |
| 128 # Replace version number in metadata file "manually", ConfigParser will mess | 126 # Replace version number in metadata file "manually", ConfigParser will mess |
| 129 # up the order of lines. | 127 # up the order of lines. |
| 130 metadata = readMetadata(baseDir, type) | 128 metadata = readMetadata(baseDir, type) |
| 131 with open(metadata.option_source('general', 'version'), 'r+b') as file: | 129 with open(metadata.option_source('general', 'version'), 'r+b') as file: |
| 132 rawMetadata = file.read() | 130 rawMetadata = file.read() |
| 133 rawMetadata = re.sub( | 131 rawMetadata = re.sub( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 144 | 142 |
| 145 with open(os.path.join(locales_base, 'chrome', 'locale', | 143 with open(os.path.join(locales_base, 'chrome', 'locale', |
| 146 packager.defaultLocale.replace('_', '-'), | 144 packager.defaultLocale.replace('_', '-'), |
| 147 'meta.json'), | 145 'meta.json'), |
| 148 'r') as fp: | 146 'r') as fp: |
| 149 extensionName = json.load(fp)['name'] | 147 extensionName = json.load(fp)['name'] |
| 150 | 148 |
| 151 # Now commit the change and tag it | 149 # Now commit the change and tag it |
| 152 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) | 150 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) |
| 153 tag_name = version | 151 tag_name = version |
| 154 if type in {'safari', 'edge'}: | 152 if type == 'edge': |
| 155 tag_name = '{}-{}'.format(tag_name, type) | 153 tag_name = '{}-{}'.format(tag_name, type) |
| 156 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) | 154 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) |
| 157 | 155 |
| 158 # Create a release build | 156 # Create a release build |
| 159 downloads = [] | 157 downloads = [] |
| 160 if type == 'chrome': | 158 if type == 'chrome': |
| 161 # Create both signed and unsigned Chrome builds (the latter for Chrome W
eb Store). | 159 # Create both signed and unsigned Chrome builds (the latter for Chrome W
eb Store). |
| 162 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'crx')) | 160 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'crx')) |
| 163 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) | 161 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) |
| 164 downloads.append(buildPath) | 162 downloads.append(buildPath) |
| 165 | 163 |
| 166 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v
ersion, 'zip')) | 164 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v
ersion, 'zip')) |
| 167 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) | 165 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) |
| 168 elif type == 'safari': | |
| 169 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'safariextz')) | |
| 170 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB
uild=True, keyFile=keyFile) | |
| 171 downloads.append(buildPath) | |
| 172 elif type == 'edge': | 166 elif type == 'edge': |
| 173 # We only offer the Edge extension for use through the Windows Store | 167 # We only offer the Edge extension for use through the Windows Store |
| 174 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'appx')) | 168 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'appx')) |
| 175 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) | 169 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) |
| 176 downloads.append(buildPath) | 170 downloads.append(buildPath) |
| 177 | 171 |
| 178 # Create source archive | 172 # Create source archive |
| 179 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 173 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
| 180 create_sourcearchive(baseDir, archivePath) | 174 create_sourcearchive(baseDir, archivePath) |
| 181 downloads.append(archivePath) | 175 downloads.append(archivePath) |
| 182 | 176 |
| 183 # Now add the downloads and commit | 177 # Now add the downloads and commit |
| 184 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 178 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
| 185 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) | 179 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) |
| 186 | 180 |
| 187 # Push all changes | 181 # Push all changes |
| 188 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 182 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
| 189 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 183 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
| OLD | NEW |