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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /* eslint-env node */
19
20 "use strict";
21
22 const path = require("path");
23 const {exec} = require("child_process");
24 const signAddon = require("sign-addon").default;
25 const fs = require("fs");
26
27 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.
28 let version = undefined;
29 let appId = undefined;
30 let auth = JSON.parse(
31 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
32
33 function execPromise(command)
34 {
35 return new Promise((resolve, reject) =>
36 {
37 exec(
38 command,
39 (error, stdout, stderr) =>
40 {
41 if (error)
42 {
43 console.error(stderr);
44 reject(error);
45 }
46 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.
47 }
48 );
49 });
50 }
51
52 function pythonMetadata(section, option)
53 {
54 let cmd = "python -c \"" +
55 "from buildtools.chainedconfigparser import ChainedConfigParser; " +
56 "p = ChainedConfigParser(); " +
57 "p.read('metadata.gecko'); " +
58 `print p.get('${section}', '${option}')"`;
59 return execPromise(cmd.trim());
60 }
61
62 let getBuildNum = execPromise("git rev-list --count --branches --tags HEAD");
63
64 Promise.all([
65 pythonMetadata("general", "version"),
66 pythonMetadata("general", "app_id_devbuild"),
67 getBuildNum
68 ]).then(([v, i, b]) =>
69 {
70 version = v;
71 buildnum = b;
72 appId = i;
73 return execPromise(
74 `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.
75 ${buildnum} adblockplusfirefox-${version}.${buildnum}.xpi"`);
76 }).then(() =>
77 signAddon({
78 xpiPath: `adblockplusfirefox-${version}.${buildnum}.xpi`,
79 version: `${version}.${buildnum}`,
80 apiKey: auth["AMO_KEY"],
81 apiSecret: auth["AMO_SECRET"],
82 channel: "unlisted",
83 id: appId
84 })
85 ).then(result =>
86 {
87 if (!result.success)
88 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,
89 });
OLDNEW
« automation/build.js ('K') | « automation/build.js ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld