Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: automation/builds/gecko.js

Issue 29901591: Issue 7020 - publish gecko with Node.js (Closed) Base URL: https://gitlab.com/eyeo/adblockplus/adblockpluschrome/tree/6323e74d580026e3bd1e8e631fcddaf0bbaa34df
Patch Set: Created Oct. 4, 2018, 3:21 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« automation/build.js ('K') | « automation/build.js ('k') | package.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: automation/builds/gecko.js
diff --git a/automation/builds/gecko.js b/automation/builds/gecko.js
new file mode 100644
index 0000000000000000000000000000000000000000..c0cfccbdd786358d61bdea93d83a1035fd60de02
--- /dev/null
+++ b/automation/builds/gecko.js
@@ -0,0 +1,89 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-present eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* eslint-env node */
+
+"use strict";
+
+const path = require("path");
+const {exec} = require("child_process");
+const signAddon = require("sign-addon").default;
+const fs = require("fs");
+
+let buildnum = undefined;
Sebastian Noack 2018/10/04 19:56:53 Do these really need to be global variables? Why?
tlucas 2018/10/15 10:26:19 Done.
+let version = undefined;
+let appId = undefined;
+let auth = JSON.parse(
+ fs.readFileSync(path.resolve(process.env.AMO_OAUTH_CREDENTIALS)));
Sebastian Noack 2018/10/04 19:56:53 I'm not sure if using sync APIs is justified here.
tlucas 2018/10/15 10:26:20 I "promisified" fs.readFile(), so that we can wait
+
+function execPromise(command)
+{
+ return new Promise((resolve, reject) =>
+ {
+ exec(
+ command,
+ (error, stdout, stderr) =>
+ {
+ if (error)
+ {
+ console.error(stderr);
+ reject(error);
+ }
+ else resolve(stdout.replace(/(\r\n|\n|\r)/gm, ""));
Sebastian Noack 2018/10/04 19:56:53 Nit: Please a new line after the else statement.
Sebastian Noack 2018/10/04 19:56:53 Do you really want to remove every new line (and i
tlucas 2018/10/15 10:26:20 It was trimming. Done.
+ }
+ );
+ });
+}
+
+function pythonMetadata(section, option)
+{
+ let cmd = "python -c \"" +
+ "from buildtools.chainedconfigparser import ChainedConfigParser; " +
+ "p = ChainedConfigParser(); " +
+ "p.read('metadata.gecko'); " +
+ `print p.get('${section}', '${option}')"`;
+ return execPromise(cmd.trim());
+}
+
+let getBuildNum = execPromise("git rev-list --count --branches --tags HEAD");
+
+Promise.all([
+ pythonMetadata("general", "version"),
+ pythonMetadata("general", "app_id_devbuild"),
+ getBuildNum
+]).then(([v, i, b]) =>
+{
+ version = v;
+ buildnum = b;
+ appId = i;
+ return execPromise(
+ `bash -c "python build.py build -t gecko -b \
Sebastian Noack 2018/10/04 19:56:53 Calling the command through bash seems unnecessary
tlucas 2018/10/15 10:26:20 Done.
+ ${buildnum} adblockplusfirefox-${version}.${buildnum}.xpi"`);
+}).then(() =>
+ signAddon({
+ xpiPath: `adblockplusfirefox-${version}.${buildnum}.xpi`,
+ version: `${version}.${buildnum}`,
+ apiKey: auth["AMO_KEY"],
+ apiSecret: auth["AMO_SECRET"],
+ channel: "unlisted",
+ id: appId
+ })
+).then(result =>
+{
+ if (!result.success)
+ process.exit(1);
Sebastian Noack 2018/10/04 19:56:52 Is there any error we can log in this case?
tlucas 2018/10/15 10:26:19 signAddon itself prints the reason to the console,
+});
« automation/build.js ('K') | « automation/build.js ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld