mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
try with shell
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
eda0923591
commit
4d7722d7ad
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
// This script creates a release PR
|
||||
import { execSync, exec, spawn } from "child_process";
|
||||
import { exec, spawn } from "child_process";
|
||||
import commandLineArgs from "command-line-args";
|
||||
import fse from "fs-extra";
|
||||
import { basename } from "path";
|
||||
@ -18,7 +18,7 @@ const {
|
||||
rcompare: semverRcompare,
|
||||
lte: semverLte,
|
||||
} = semver;
|
||||
const { readJsonSync } = fse;
|
||||
const { readJson } = fse;
|
||||
const execP = promisify(exec);
|
||||
|
||||
const options = commandLineArgs([
|
||||
@ -81,16 +81,17 @@ if (basename(process.cwd()) === "scripts") {
|
||||
console.error(errorMessages.wrongCwd);
|
||||
}
|
||||
|
||||
|
||||
const currentVersion = new SemVer(readJsonSync("./package.json").version);
|
||||
const currentPackageJson = await readJson("./package.json");
|
||||
const currentVersion = new SemVer(currentPackageJson.version);
|
||||
const currentVersionMilestone = `${currentVersion.major}.${currentVersion.minor}.${currentVersion.patch}`;
|
||||
|
||||
console.log(`current version: ${currentVersion.format()}`);
|
||||
console.log("fetching tags...");
|
||||
execSync("git fetch --tags --force");
|
||||
await execP("git fetch --tags --force");
|
||||
|
||||
const prBase = execSync("git branch --show-current", { encoding: "utf-8" });
|
||||
const actualTags = execSync("git tag --list", { encoding: "utf-8" }).split(/\r?\n/).map(line => line.trim());
|
||||
const prBase = (await execP("git branch --show-current", { encoding: "utf-8" })).stdout;
|
||||
const tagListBody = (await execP("git tag --list", { encoding: "utf-8" })).stdout;
|
||||
const actualTags = tagListBody.split(/\r?\n/).map(line => line.trim());
|
||||
const [previousReleasedVersion] = actualTags
|
||||
.map(semverValid)
|
||||
.filter(Boolean)
|
||||
@ -110,12 +111,13 @@ if (options.preid) {
|
||||
npmVersionArgs.push("--git-tag-version false");
|
||||
|
||||
try {
|
||||
execSync(npmVersionArgs.join(" "));
|
||||
await execP(npmVersionArgs.join(" "));
|
||||
} catch (error) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const newVersion = new SemVer(readJsonSync("./package.json").version);
|
||||
const newPackageJson = await readJson("./package.json");
|
||||
const newVersion = new SemVer(newPackageJson.version);
|
||||
|
||||
const getMergedPrsArgs = [
|
||||
"gh",
|
||||
@ -128,7 +130,7 @@ const getMergedPrsArgs = [
|
||||
];
|
||||
|
||||
console.log("retreiving last 500 PRs to create release PR body...");
|
||||
const mergedPrs = JSON.parse(execSync(getMergedPrsArgs.join(" "), { encoding: "utf-8" }));
|
||||
const mergedPrs = JSON.parse((await execP(getMergedPrsArgs.join(" "), { encoding: "utf-8" })).stdout);
|
||||
const milestoneRelevantPrs = mergedPrs.filter(pr => pr.milestone && pr.milestone.title === currentVersionMilestone);
|
||||
const relaventPrsQuery = await Promise.all(
|
||||
milestoneRelevantPrs.map(async pr => ({
|
||||
@ -184,20 +186,21 @@ if (maintenencePrs.length > 0) {
|
||||
);
|
||||
}
|
||||
|
||||
execSync(`git push origin HEAD -u`);
|
||||
await execP(`git push origin HEAD -u`);
|
||||
|
||||
const prBody = prBodyLines.join("\n");
|
||||
|
||||
const createPrArgs = [
|
||||
"pr",
|
||||
"create",
|
||||
"--base", prBase,
|
||||
"--title", `release ${newVersion.format()}`,
|
||||
"--title", `"Release ${newVersion.format()}"`,
|
||||
"--label", "skip-changelog",
|
||||
"--body-file", "-",
|
||||
];
|
||||
|
||||
const createPrProcess = spawn("gh", createPrArgs, { stdio: "pipe" });
|
||||
console.log(createPrArgs.join(" "));
|
||||
|
||||
const createPrProcess = spawn("gh", createPrArgs, { stdio: "pipe", shell: true });
|
||||
let result = "";
|
||||
let errorResult = "";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user