-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuilder.php
35 lines (23 loc) · 1.12 KB
/
builder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
$base = __DIR__;
$changeLog = file_get_contents("$base/src/chrome/options.html");
preg_match('#<ul id="changelog">.*?<aside>([\d.]+)</aside>#s', $changeLog, $res);
isset($res[1]) or die('Cannot fetch previous version!');
$newVersion = $res[1];
$oldVersion = json_decode(file_get_contents("$base/src/chrome/manifest.json"))->version;
// Make sure the new version is larger than the previous.
if (version_compare($newVersion, $oldVersion) < 0) {
die('The new version needs to be larger than the previous.');
}
file_exists("$base/builds") or mkdir("$base/builds");
foreach (['chrome', 'firefox'] as $browser) {
echo "Handling $browser...\n";
$contents = file_get_contents($path = "$base/src/$browser/manifest.json");
$contents = preg_replace('/"version": "[^"]+",/', '"version": "' . $newVersion . '",', $contents);
// Update the new version in the manifest files.
file_put_contents($path, $contents);
echo "\tnew version OK\n";
// Create the zip file for the current browser.
exec("cd $base/src/$browser && zip -r ../../builds/$browser-$newVersion.zip ./");
echo "\tZIP file OK\n\n";
}