Kyle Brennan 3c4818f017
[ci] wait 5m on publish to yarn register before timing out (#18830)
This times out in 100 seconds, and is causing failures for builds in main.

Maybe it needs more time.
2023-09-28 01:23:06 +03:00

54 lines
1.4 KiB
JavaScript

/**
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License.AGPL.txt in the project root for license information.
*/
// @ts-check
const fs = require("fs");
const path = require("path");
const child_process = require("child_process");
const qualifier = process.argv[2];
const rootDir = process.cwd();
const pckDir = path.join(rootDir, process.argv[3]);
if (process.env.DO_PUBLISH === "false") {
console.warn("Skipping publishing per request.");
process.exit(0);
}
if (process.env.NPM_AUTH_TOKEN) {
fs.writeFileSync(
path.join(pckDir, ".npmrc"),
`//registry.npmjs.org/:_authToken=${process.env.NPM_AUTH_TOKEN}\n`,
"utf-8",
);
} else {
console.warn("NPM_AUTH_TOKEN env variable is not set");
}
const pck = JSON.parse(fs.readFileSync(path.join(pckDir, "package.json"), "utf-8"));
pck.version = `${pck.version}-${qualifier}`;
fs.writeFileSync(path.join(pckDir, "package.json"), JSON.stringify(pck, undefined, 2), "utf-8");
const tag = qualifier.substr(0, qualifier.lastIndexOf("."));
child_process.execSync(
[
"yarn",
"--cwd",
pckDir,
"publish",
"--tag",
tag,
"--access",
"public",
"--ignore-scripts",
"--network-timeout",
"300000",
].join(" "),
{ stdio: "inherit" },
);