Release script: choose version instead of passing argument (#16381)
This commit is contained in:
1 parent
fe7b985d67
commit
2c43f7d292
5 files changed
+43
-4
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
node ./scripts/release/release.js --version NEW_VERSION
|
node ./scripts/release/release.js
|
||||||
```
|
```
|
||||||
|
|
||||||
The script has its own `package.json` so we can reinstall the root's `node_modules/` while making the release.
|
The script has its own `package.json` so we can reinstall the root's `node_modules/` while making the release.
|
||||||
@@ -12,6 +12,7 @@ The script has its own `package.json` so we can reinstall the root's `node_modul
|
|||||||
|
|
||||||
| Flag | Description |
|
| Flag | Description |
|
||||||
| ----------------------------- | --------------------------------------------------------------------------------------- |
|
| ----------------------------- | --------------------------------------------------------------------------------------- |
|
||||||
|
| `--version` | Version to release |
|
||||||
| `--manual` | Manual run release process instead of publish from GitHub actions |
|
| `--manual` | Manual run release process instead of publish from GitHub actions |
|
||||||
| `--dry` | Dry run |
|
| `--dry` | Dry run |
|
||||||
| `--skip-dependencies-install` | Skip dependencies installation |
|
| `--skip-dependencies-install` | Skip dependencies installation |
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ if (semver.parse(previousVersion) === null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let step of [
|
for (let step of [
|
||||||
|
{
|
||||||
|
process: steps.chooseVersion,
|
||||||
|
skip: Boolean(params.version),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Validating new version",
|
name: "Validating new version",
|
||||||
process: steps.validateNewVersion,
|
process: steps.validateNewVersion,
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import semver from "semver";
|
|||||||
import { logPromise, readJson, runGit, runYarn, writeJson } from "../utils.js";
|
import { logPromise, readJson, runGit, runYarn, writeJson } from "../utils.js";
|
||||||
|
|
||||||
async function format() {
|
async function format() {
|
||||||
await runYarn(["lint:eslint", "--fix"]);
|
await runYarn(["fix:prettier"]);
|
||||||
await runYarn(["lint:prettier", "--write"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add commit to `.git-blame-ignore-revs` when files except `package.json` and `yarn.lock` changed
|
// Only add commit to `.git-blame-ignore-revs` when files except `package.json` and `yarn.lock` changed
|
||||||
@@ -66,6 +65,6 @@ export default async function bumpPrettier(params) {
|
|||||||
"Installing Prettier",
|
"Installing Prettier",
|
||||||
runYarn(["add", "--dev", `prettier@${version}`]),
|
runYarn(["add", "--dev", `prettier@${version}`]),
|
||||||
);
|
);
|
||||||
await logPromise("Updating files", format());
|
await logPromise("Formatting files", format());
|
||||||
await logPromise("Committing changed files", commit(params));
|
await logPromise("Committing changed files", commit(params));
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import enquirer from "enquirer";
|
||||||
|
import semver from "semver";
|
||||||
|
|
||||||
|
const SEMVER_INCREMENTS = ["patch", "minor", "major"];
|
||||||
|
const CUSTOM_VERSION_VALUE_PLACEHOLDER = "custom-version";
|
||||||
|
|
||||||
|
export default async function chooseVersion(params) {
|
||||||
|
let version = await new enquirer.Select({
|
||||||
|
name: "version",
|
||||||
|
message: `Choose a version to release (current: ${params.previousVersion})`,
|
||||||
|
choices: [
|
||||||
|
...SEMVER_INCREMENTS.map((type) => {
|
||||||
|
const version = semver.inc(params.previousVersion, type);
|
||||||
|
|
||||||
|
return {
|
||||||
|
message: `${type}: ${version}`,
|
||||||
|
value: version,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
{ role: "separator" },
|
||||||
|
{ message: "Other", value: CUSTOM_VERSION_VALUE_PLACEHOLDER },
|
||||||
|
],
|
||||||
|
}).run();
|
||||||
|
|
||||||
|
if (version === CUSTOM_VERSION_VALUE_PLACEHOLDER) {
|
||||||
|
({ version } = await enquirer.prompt({
|
||||||
|
type: "input",
|
||||||
|
name: "version",
|
||||||
|
message: `Input version (current: ${params.previousVersion})`,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
params.version = version;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export { default as bumpPrettier } from "./bump-prettier.js";
|
export { default as bumpPrettier } from "./bump-prettier.js";
|
||||||
export { default as checkGitStatus } from "./check-git-status.js";
|
export { default as checkGitStatus } from "./check-git-status.js";
|
||||||
|
export { default as chooseVersion } from "./choose-version.js";
|
||||||
export { default as cleanChangelog } from "./clean-changelog.js";
|
export { default as cleanChangelog } from "./clean-changelog.js";
|
||||||
export { default as generateBundles } from "./generate-bundles.js";
|
export { default as generateBundles } from "./generate-bundles.js";
|
||||||
export { default as installDependencies } from "./install-dependencies.js";
|
export { default as installDependencies } from "./install-dependencies.js";
|
||||||
|
|||||||
Reference in new issue
Block a user