Skip to content

Commit cb9934f

Browse files
committed
Fix publish scripts for dev build versions
1 parent e714026 commit cb9934f

3 files changed

Lines changed: 35 additions & 28 deletions

File tree

dist/chromium/publish-beta.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
while not os.path.isdir(os.path.join(projdir, '.git')):
2828
projdir = os.path.normpath(os.path.join(projdir, '..'))
2929

30-
cs_extension_id = 'eckgcipdkhcfghnmincccnhpdmnbefki'
31-
tmpdir = tempfile.TemporaryDirectory()
32-
raw_zip_filename = 'uMatrix.chromium.zip'
33-
raw_zip_filepath = os.path.join(tmpdir.name, raw_zip_filename)
34-
github_owner = 'gorhill'
35-
github_repo = 'uMatrix'
36-
3730
# We need a version string to work with
3831
if len(sys.argv) >= 2 and sys.argv[1]:
3932
version = sys.argv[1]
@@ -44,6 +37,13 @@
4437
print('Error: Invalid version string.')
4538
exit(1)
4639

40+
cs_extension_id = 'eckgcipdkhcfghnmincccnhpdmnbefki'
41+
tmpdir = tempfile.TemporaryDirectory()
42+
raw_zip_filename = 'uMatrix.chromium.zip'
43+
raw_zip_filepath = os.path.join(tmpdir.name, raw_zip_filename)
44+
github_owner = 'gorhill'
45+
github_repo = 'uMatrix'
46+
4747
# Load/save auth secrets
4848
# The build directory is excluded from git
4949
ubo_secrets = dict()

dist/firefox/publish-signed-beta.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@
4242
print('Version file not found.')
4343
exit(1)
4444

45+
# We need a version string to work with
46+
if len(sys.argv) >= 2 and sys.argv[1]:
47+
tag_version = sys.argv[1]
48+
else:
49+
tag_version = input('Github release version: ')
50+
tag_version.strip()
51+
match = re.search('^(\d+\.\d+\.\d+)(?:(b|rc)(\d+))?$', tag_version)
52+
if not match:
53+
print('Error: Invalid version string.')
54+
exit(1)
55+
ext_version = match.group(1);
56+
if match.group(2):
57+
revision = int(match.group(3))
58+
if match.group(2) == 'rc':
59+
revision += 100;
60+
ext_version += '.' + str(revision)
61+
4562
extension_id = '[email protected]'
4663
tmpdir = tempfile.TemporaryDirectory()
4764
raw_xpi_filename = 'uMatrix.firefox.xpi'
@@ -52,16 +69,6 @@
5269
github_owner = 'gorhill'
5370
github_repo = 'uMatrix'
5471

55-
# We need a version string to work with
56-
if len(sys.argv) >= 2 and sys.argv[1]:
57-
version = sys.argv[1]
58-
else:
59-
version = input('Github release version: ')
60-
version.strip()
61-
if not re.search('^\d+\.\d+\.\d+(b|rc)\d+$', version):
62-
print('Error: Invalid version string.')
63-
exit(1)
64-
6572
# Load/save auth secrets
6673
# The build directory is excluded from git
6774
ubo_secrets = dict()
@@ -99,7 +106,7 @@ def input_secret(prompt, token):
99106

100107
# https://developer.github.com/v3/repos/releases/#get-a-single-release
101108
print('Downloading release info from GitHub...')
102-
release_info_url = 'https://api.github.com/repos/{0}/{1}/releases/tags/{2}'.format(github_owner, github_repo, version)
109+
release_info_url = 'https://api.github.com/repos/{0}/{1}/releases/tags/{2}'.format(github_owner, github_repo, tag_version)
103110
headers = { 'Authorization': github_auth, }
104111
response = requests.get(release_info_url, headers=headers)
105112
if response.status_code != 200:
@@ -154,7 +161,7 @@ def input_secret(prompt, token):
154161
data = zipin.read(item.filename)
155162
if item.filename == 'manifest.json':
156163
manifest = json.loads(bytes.decode(data))
157-
manifest['applications']['gecko']['update_url'] = 'https://raw.githubusercontent.com/{0}/{1}/master/dist/firefox/updates.json'.format(github_owner, github_repo)
164+
manifest['browser_specific_settings']['gecko']['update_url'] = 'https://raw.githubusercontent.com/{0}/{1}/master/dist/firefox/updates.json'.format(github_owner, github_repo)
158165
data = json.dumps(manifest, indent=2, separators=(',', ': '), sort_keys=True).encode()
159166
zipout.writestr(item, data)
160167

@@ -181,7 +188,7 @@ def input_secret(prompt, token):
181188
headers = { 'Authorization': jwt_auth, }
182189
data = { 'channel': 'unlisted' }
183190
files = { 'upload': f, }
184-
signing_url = 'https://addons.mozilla.org/api/v3/addons/{0}/versions/{1}/'.format(extension_id, version)
191+
signing_url = 'https://addons.mozilla.org/api/v3/addons/{0}/versions/{1}/'.format(extension_id, ext_version)
185192
print('Submitting package to be signed...')
186193
response = requests.put(signing_url, headers=headers, data=data, files=files)
187194
if response.status_code != 202:
@@ -278,11 +285,11 @@ def input_secret(prompt, token):
278285
updates_json = json.load(f)
279286
f.close()
280287
previous_version = updates_json['addons'][extension_id]['updates'][0]['version']
281-
if LooseVersion(version) > LooseVersion(previous_version):
288+
if LooseVersion(ext_version) > LooseVersion(previous_version):
282289
with open(os.path.join(projdir, 'dist', 'firefox', 'updates.template.json')) as f:
283290
template_json = Template(f.read())
284291
f.close()
285-
updates_json = template_json.substitute(version=version)
292+
updates_json = template_json.substitute(ext_version=ext_version, tag_version=tag_version)
286293
with open(updates_json_filepath, 'w') as f:
287294
f.write(updates_json)
288295
f.close()
@@ -296,7 +303,7 @@ def input_secret(prompt, token):
296303
r = subprocess.run(['git', 'status', '-s', updates_json_filepath], stdout=subprocess.PIPE)
297304
rout = bytes.decode(r.stdout).strip()
298305
if len(rout) >= 2 and rout[0] == 'M':
299-
subprocess.run(['git', 'commit', '-m', 'make Firefox dev build auto-update', updates_json_filepath])
300-
subprocess.run(['git', 'push', 'origin', 'master'])
306+
subprocess.run(['git', 'commit', '-m', 'Make Firefox dev build auto-update', updates_json_filepath])
307+
subprocess.run(['git', 'push', 'origin', 'HEAD'])
301308

302309
print('All done.')

dist/firefox/updates.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
44
"updates": [
55
{
6-
"version": "1.3.17rc4",
7-
"applications": { "gecko": { "strict_min_version": "56" } },
8-
"update_info_url": "https://github.com/gorhill/uMatrix/releases/tag/1.3.17rc4",
9-
"update_link": "https://github.com/gorhill/uMatrix/releases/download/1.3.17rc4/uMatrix.firefox.signed.xpi"
6+
"version": "1.4.1b0",
7+
"browser_specific_settings": { "gecko": { "strict_min_version": "56" } },
8+
"update_info_url": "https://github.com/gorhill/uMatrix/releases/tag/1.4.1b0",
9+
"update_link": "https://github.com/gorhill/uMatrix/releases/download/1.4.1b0/uMatrix.firefox.signed.xpi"
1010
}
1111
]
1212
}

0 commit comments

Comments
 (0)