Add --next flag to release script (#15816)
Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
1 parent
6a6b699a42
commit
863368e1ba
11 files changed
+55
-18
No files matched your search
@@ -10,9 +10,12 @@ The script has its own `package.json` so we can reinstall the root's `node_modul
|
||||
|
||||
## Flags
|
||||
|
||||
- `--manual` Manual run release process instead of publish from GitHub actions
|
||||
- `--dry` Dry run
|
||||
- `--skip-dependencies-install` Skip dependencies installation
|
||||
| Flag | Description |
|
||||
| ----------------------------- | --------------------------------------------------------------------------------------- |
|
||||
| `--manual` | Manual run release process instead of publish from GitHub actions |
|
||||
| `--dry` | Dry run |
|
||||
| `--skip-dependencies-install` | Skip dependencies installation |
|
||||
| `--next` | Pre-release such as alpha and beta. It must be run on the `next` branch or it will fail |
|
||||
|
||||
## Credits
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ function parseArguments() {
|
||||
manual = false,
|
||||
dry = false,
|
||||
"skip-dependencies-install": skipDependenciesInstall = false,
|
||||
next = false,
|
||||
},
|
||||
} = parseArgs({
|
||||
options: {
|
||||
@@ -26,6 +27,9 @@ function parseArguments() {
|
||||
"skip-dependencies-install": {
|
||||
type: "boolean",
|
||||
},
|
||||
next: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -35,6 +39,7 @@ function parseArguments() {
|
||||
manual,
|
||||
dry,
|
||||
skipDependenciesInstall,
|
||||
next,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ async function bump({
|
||||
}
|
||||
|
||||
export default async function bumpPrettier(params) {
|
||||
const { dry, version } = params;
|
||||
const { dry, version, next } = params;
|
||||
|
||||
if (dry) {
|
||||
if (dry || next) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { runGit } from "../utils.js";
|
||||
|
||||
export default async function checkGitStatus() {
|
||||
export default async function checkGitStatus({ next }) {
|
||||
const { stdout: status } = await runGit(["status", "--porcelain"]);
|
||||
|
||||
if (status) {
|
||||
@@ -9,4 +9,13 @@ export default async function checkGitStatus() {
|
||||
"Please revert or commit all local changes before making a release.",
|
||||
);
|
||||
}
|
||||
|
||||
if (next) {
|
||||
const { stdout: branch } = await runGit(["branch", "--show-current"]);
|
||||
if (branch !== "next") {
|
||||
throw new Error(
|
||||
`Expected to be on "next" branch, but currently on "${branch}"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,10 +45,10 @@ function twitterAnnouncement() {
|
||||
`;
|
||||
}
|
||||
|
||||
export default async function postPublishSteps({ dry }) {
|
||||
export default async function postPublishSteps({ dry, next }) {
|
||||
console.log(chalk.bold.green("The script has finished!\n"));
|
||||
|
||||
if (dry) {
|
||||
if (dry || next) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,15 @@ export function getReleaseUrl(version, previousVersion) {
|
||||
export default async function showInstructionsAfterNpmPublish({
|
||||
version,
|
||||
previousVersion,
|
||||
next,
|
||||
}) {
|
||||
const releaseUrl = getReleaseUrl(version, previousVersion);
|
||||
if (next) {
|
||||
console.log(`${chalk.green.bold(`Prettier ${version} published!`)}`);
|
||||
await waitForEnter();
|
||||
return;
|
||||
}
|
||||
|
||||
const releaseUrl = getReleaseUrl(version, previousVersion);
|
||||
console.log(
|
||||
outdent`
|
||||
${chalk.green.bold(`Prettier ${version} published!`)}
|
||||
|
||||
@@ -31,8 +31,9 @@ export default async function updateChangelog({
|
||||
dry,
|
||||
version,
|
||||
previousVersion,
|
||||
next,
|
||||
}) {
|
||||
if (dry) {
|
||||
if (dry || next) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ function formatNumber(value) {
|
||||
return Math.floor(value / 1e5) / 10 + " million";
|
||||
}
|
||||
|
||||
export default async function updateDependentsCount({ dry }) {
|
||||
if (dry) {
|
||||
export default async function updateDependentsCount({ dry, next }) {
|
||||
if (dry || next) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { runYarn, readJson, writeJson, processFile } from "../utils.js";
|
||||
|
||||
export default async function updateVersion({ version }) {
|
||||
export default async function updateVersion({ version, next }) {
|
||||
const pkg = await readJson("package.json");
|
||||
pkg.version = version;
|
||||
await writeJson("package.json", pkg);
|
||||
|
||||
// For pre-release, just update package.json
|
||||
if (next) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update github issue templates
|
||||
processFile(".github/ISSUE_TEMPLATE/formatting.md", (content) =>
|
||||
content.replace(/^(\*\*Prettier ).*?(\*\*)$/m, `$1${version}$2`),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import chalk from "chalk";
|
||||
import semver from "semver";
|
||||
|
||||
export default function validateNewVersion({ version, previousVersion }) {
|
||||
export default function validateNewVersion({ version, previousVersion, next }) {
|
||||
if (!version) {
|
||||
throw new Error("'--version' is required");
|
||||
}
|
||||
@@ -17,4 +17,12 @@ export default function validateNewVersion({ version, previousVersion }) {
|
||||
`Version '${chalk.yellow.underline(version)}' has already been published`,
|
||||
);
|
||||
}
|
||||
|
||||
if (next && semver.prerelease(version) === null) {
|
||||
throw new Error(
|
||||
`Version '${chalk.yellow.underline(
|
||||
version,
|
||||
)}' is not a prerelease version`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ const sleep = () =>
|
||||
setTimeout(resolve, 30_000);
|
||||
});
|
||||
|
||||
export default async function waitForBotRelease({ dry, version }) {
|
||||
export default async function waitForBotRelease({ dry, version, next }) {
|
||||
if (dry) {
|
||||
return;
|
||||
}
|
||||
@@ -68,9 +68,9 @@ export default async function waitForBotRelease({ dry, version }) {
|
||||
"Run workflow",
|
||||
)}" button, type "${chalk.yellow.underline(
|
||||
version,
|
||||
)}" in "Version to release", uncheck all checkboxes, hit the "${chalk.bgGreen(
|
||||
"Run workflow",
|
||||
)}" button.
|
||||
)}" in "Version to release", ${
|
||||
next ? 'check only "Unstable version"' : "uncheck all checkboxes"
|
||||
}, hit the "${chalk.bgGreen("Run workflow")}" button.
|
||||
`,
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user