Skip to content
Closed
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions tools/release/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ const repositoryPathOption = [
'--repository-path <repository-path>',
'Relative path to the git repository.',
];
const releaseIdOption = [
'--release-id <release-id>',
'Stable identifier used to resume the same release.',
];

program
.command( 'publish-npm-packages-latest' )
.alias( 'npm-latest' )
.option( ...semverOption )
.option( ...ciOption )
.option( ...releaseIdOption )
.option( ...repositoryPathOption )
.description(
'Publishes to npm packages synced from the Gutenberg plugin (latest dist-tag, production version)'
Expand All @@ -39,6 +44,7 @@ program
.command( 'publish-npm-packages-bugfix-latest' )
.alias( 'npm-bugfix' )
.option( ...ciOption )
.option( ...releaseIdOption )
.option( ...repositoryPathOption )
.description(
'Publishes to npm bugfixes for packages (latest dist-tag, production version)'
Expand All @@ -50,6 +56,7 @@ program
.alias( 'npm-wp' )
.requiredOption( '--wp-version <wpVersion>', 'WordPress version' )
.option( ...ciOption )
.option( ...releaseIdOption )
.option( ...repositoryPathOption )
.description(
'Publishes to npm bugfixes targeting WordPress core (wp-X.Y dist-tag, production version)'
Expand All @@ -61,6 +68,7 @@ program
.alias( 'npm-next' )
.option( ...semverOption )
.option( ...ciOption )
.option( ...releaseIdOption )
.option( ...repositoryPathOption )
.description(
'Publishes to npm development version of packages (next dist-tag, prerelease version)'
Expand Down
25 changes: 12 additions & 13 deletions tools/release/commands/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@
const semver = require( 'semver' );
const SimpleGit = require( 'simple-git' );

/**
* Internal dependencies
*/
const { readJSONFile } = require( '../lib/utils' );

/**
* Finds the name of the current plugin release branch based on the version in
* the package.json file and the latest `trunk` branch in `git`.
* the package.json file at the latest `trunk` commit in `git`.
*
* @param {string} gitWorkingDirectoryPath Path to the project's working directory.
* @param {Object} deps Dependencies.
* @param {Object} deps.git Git client.
*
* @return {string} Name of the plugin release branch.
*/
async function findPluginReleaseBranchName( gitWorkingDirectoryPath ) {
await SimpleGit( gitWorkingDirectoryPath )
.fetch( 'origin', 'trunk' )
.checkout( 'trunk' );

const packageJsonPath = gitWorkingDirectoryPath + '/package.json';
const mainPackageJson = readJSONFile( packageJsonPath );
async function findPluginReleaseBranchName(
gitWorkingDirectoryPath,
deps = {}
) {
const { git = SimpleGit( gitWorkingDirectoryPath ) } = deps;
await git.fetch( 'origin', 'trunk', [ '--depth=1' ] );
const mainPackageJson = JSON.parse(
await git.show( 'FETCH_HEAD:package.json' )
);
Comment thread
ciampo marked this conversation as resolved.
Resolved
const mainParsedVersion = semver.parse( mainPackageJson.version );

return 'release/' + mainParsedVersion.major + '.' + mainParsedVersion.minor;
Expand Down
Loading
Loading