Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages: Make it possible to select minimum version bump for publishing #27459

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions bin/plugin/commands/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const glob = require( 'fast-glob' );
const fs = require( 'fs' );
const semver = require( 'semver' );
const readline = require( 'readline' );
const { prompt } = require( 'inquirer' );

/**
* Internal dependencies
Expand All @@ -20,6 +21,12 @@ const {
} = require( './common' );
const git = require( '../lib/git' );

/**
* Semantic Versioning labels.
*
* @typedef {('major'|'minor'|'patch')} SemVer
*/

/**
* Checks out the WordPress release branch and syncs it with the changes from
* the last plugin release.
Expand Down Expand Up @@ -88,7 +95,7 @@ async function runWordPressReleaseBranchSyncStep(
* contain new entries.
*
* @param {string} gitWorkingDirectoryPath Git working directory path.
* @param {string} minimumVersionBump Minimum version bump for the packages.
* @param {SemVer} minimumVersionBump Minimum version bump for the packages.
* @param {boolean} isPrerelease Whether the package version to publish is a prerelease.
* @param {string} abortMessage Abort Message.
*/
Expand Down Expand Up @@ -238,12 +245,11 @@ async function runPushGitChangesStep(
/**
* Prepare everything to publish WordPress packages to npm.
*
* @param {string} minimumVersionBump Minimum version bump for the packages.
* @param {boolean} isPrerelease Whether the package version to publish is a prerelease.
* @param {boolean} [isPrerelease] Whether the package version to publish is a prerelease.
*
* @return {Promise<Object>} Github release object.
*/
async function prepareForPackageRelease( minimumVersionBump, isPrerelease ) {
async function prepareForPackageRelease( isPrerelease ) {
// This is a variable that contains the abort message shown when the script is aborted.
let abortMessage = 'Aborting!';
const temporaryFolders = [];
Expand All @@ -261,6 +267,16 @@ async function prepareForPackageRelease( minimumVersionBump, isPrerelease ) {
abortMessage
);

const { minimumVersionBump } = await prompt( [
{
type: 'list',
name: 'minimumVersionBump',
message: 'Select the minimum version bump for packages:',
default: 'patch',
choices: [ 'patch', 'minor', 'major' ],
},
] );

await updatePackages(
gitWorkingDirectoryPath,
minimumVersionBump,
Expand All @@ -280,6 +296,9 @@ async function prepareForPackageRelease( minimumVersionBump, isPrerelease ) {
await runCleanLocalFoldersStep( temporaryFolders, abortMessage );
}

/**
* Prepares everything for publishing a new stable version of WordPress packages.
*/
async function prepareLatestDistTag() {
log(
formats.title(
Expand All @@ -289,7 +308,7 @@ async function prepareLatestDistTag() {
"To perform a release you'll have to be a member of the WordPress Team on npm.\n"
);

await prepareForPackageRelease( 'patch' );
await prepareForPackageRelease();

log(
'\n>> 🎉 WordPress packages are ready to publish!\n',
Expand All @@ -298,6 +317,9 @@ async function prepareLatestDistTag() {
);
}

/**
* Prepares everything for publishing a new RC version of WordPress packages.
*/
async function prepareNextDistTag() {
log(
formats.title(
Expand All @@ -307,7 +329,7 @@ async function prepareNextDistTag() {
"To perform a release you'll have to be a member of the WordPress Team on npm.\n"
);

await prepareForPackageRelease( 'minor', true );
await prepareForPackageRelease( true );

log(
'\n>> 🎉 WordPress packages are ready to publish!\n',
Expand Down