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

Add "generate release notes" class/function/command #11

Open
remcotolsma opened this issue Jul 20, 2023 · 0 comments
Open

Add "generate release notes" class/function/command #11

remcotolsma opened this issue Jul 20, 2023 · 0 comments
Assignees

Comments

@remcotolsma
Copy link
Member

remcotolsma commented Jul 20, 2023

Currently we generate the release notes quite late in the version command:

The version command does several things, but this is not immediately clear to users beforehand.

  • git pull
  • Working tree status (git status)
  • git branch --show-current
  • Check tagnames without v prefix.'
  • Run Composer script preversion
  • Check composer.json type property.
  • Check composer outdated
  • Check non-comparable Composer package versions (dev-*)
  • Check package.json version property
  • Check WordPress plugin file headers from *.php files
  • Check multiple WordPress plugins in working directory
  • Ask user for bump method (patch, minor, major)
  • Compose changelog
  • Set plugin file header version
  • Set theme style.css header version
  • Set Stable tag in readme.txt header
  • Set version in package.json
  • Run Composer script version
  • Git commit changes (git commit)
  • Git tag (git tag)
  • Git push (git push)
  • Run Composer script postversion

/**
* If CHANGELOG.md check if new version is part of it?
*/
$file_changelog_md = $cwd . '/CHANGELOG.md';
if ( ! is_readable( $file_changelog_md ) ) {
$io->note( 'It is a good idea to keep track of the changes in a `CHANGELOG.md` file: https://keepachangelog.com/.' );
}
if ( is_readable( $file_changelog_md ) ) {
/**
* Remote URL.
*
* @link https://github.com/cookpete/auto-changelog/blob/0991f17ce936a9db490e2ad1a04121755038b78d/src/remote.js
*/
$process = $this->new_process( 'git remote get-url origin', $cwd );
$process_helper->mustRun( $output, $process );
$url = $process->getOutput();
$components = $this->parse_git_url( $url );
$url_repository = 'https://' . $components['host'] . '/' . $components['organisation'] . '/' . $components['repository'];
$changelog = new Changelog( $file_changelog_md );
if ( ! $changelog->has_entry( $new_version ) ) {
$changelog_entry = $changelog->new_entry( $new_version );
$changelog_entry->url = $url_repository;
$changelog_entry->version_previous = $version;
$changelog_entry->body .= $this->add_git_log( $cwd, $version, $output, $url_repository );
if ( isset( $composer_json ) ) {
$changelog_entry->body .= $this->generate_composer_json_changelog( $cwd, $version, $output );
}
$choice = '';
$iteration = 0;
while ( 'ok' !== $choice ) {
$iteration++;
$io->title( 'Changelog' );
$io->text( $changelog_entry->body );
$choice = $io->choice(
'🔁 ' . $iteration . ': Is the above changelog OK?',
[
'ok',
'subl',
],
'subl'
);
if ( 'subl' === $choice ) {
$process = $this->new_process( 'subl -', $cwd, null, $changelog_entry->body );
$process_helper->mustRun( $output, $process );
$changelog_entry->body = $process->getOutput();
}
}
$changelog_entry_string = trim( $changelog_entry->render() ) . "\n\n";
$changelog->insert( $changelog->get_insert_position(), $changelog_entry_string );
$changelog->save();
}
}

It would be more convenient if we could generate and display the changelog before the "Ask user for bump method". Based on the generated changelog, a user can more easily choose the desired bump method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant