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 == '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( |
134 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, | 132 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, |
135 rawMetadata, flags=re.I | re.M | 133 rawMetadata, flags=re.I | re.M |
136 ) | 134 ) |
137 | 135 |
138 file.seek(0) | 136 file.seek(0) |
139 file.write(rawMetadata) | 137 file.write(rawMetadata) |
140 file.truncate() | 138 file.truncate() |
141 | 139 |
142 # Read extension name from locale data | 140 # Read extension name from locale data |
143 default_locale_path = os.path.join('_locales', packager.defaultLocale, | 141 default_locale_path = os.path.join('_locales', packager.defaultLocale, |
144 'messages.json') | 142 'messages.json') |
145 with open(default_locale_path, 'r') as fp: | 143 with open(default_locale_path, 'r') as fp: |
146 extensionName = json.load(fp)['name'] | 144 extensionName = json.load(fp)['name'] |
147 | 145 |
148 # Now commit the change and tag it | 146 # Now commit the change and tag it |
149 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) | 147 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) |
150 tag_name = version | 148 tag_name = version |
151 if type in {'safari', 'edge'}: | 149 if type == 'edge': |
152 tag_name = '{}-{}'.format(tag_name, type) | 150 tag_name = '{}-{}'.format(tag_name, type) |
153 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) | 151 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) |
154 | 152 |
155 # Create a release build | 153 # Create a release build |
156 downloads = [] | 154 downloads = [] |
157 if type == 'chrome': | 155 if type == 'chrome': |
158 # Create both signed and unsigned Chrome builds (the latter for Chrome W
eb Store). | 156 # Create both signed and unsigned Chrome builds (the latter for Chrome W
eb Store). |
159 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'crx')) | 157 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'crx')) |
160 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) | 158 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) |
161 downloads.append(buildPath) | 159 downloads.append(buildPath) |
162 | 160 |
163 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v
ersion, 'zip')) | 161 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v
ersion, 'zip')) |
164 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) | 162 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) |
165 elif type == 'safari': | |
166 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'safariextz')) | |
167 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB
uild=True, keyFile=keyFile) | |
168 downloads.append(buildPath) | |
169 elif type == 'edge': | 163 elif type == 'edge': |
170 # We only offer the Edge extension for use through the Windows Store | 164 # We only offer the Edge extension for use through the Windows Store |
171 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'appx')) | 165 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'appx')) |
172 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) | 166 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) |
173 downloads.append(buildPath) | 167 downloads.append(buildPath) |
174 | 168 |
175 # Create source archive | 169 # Create source archive |
176 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 170 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
177 create_sourcearchive(baseDir, archivePath) | 171 create_sourcearchive(baseDir, archivePath) |
178 downloads.append(archivePath) | 172 downloads.append(archivePath) |
179 | 173 |
180 # Now add the downloads and commit | 174 # Now add the downloads and commit |
181 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 175 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
182 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) | 176 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) |
183 | 177 |
184 # Push all changes | 178 # Push all changes |
185 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 179 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
186 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 180 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
OLD | NEW |