automattic/jetpack-changelogger
Automattic’s Jetpack Changelogger helps you create and manage changelog entries with a simple workflow, keeping releases consistent across projects. Designed for Jetpack development, it streamlines collecting notes and generating clean, structured changelogs.
## Getting Started
### Minimal Setup
1. **Installation**:
```bash
composer require --dev automattic/jetpack-changelogger
Ensure the changelog directory exists with a .gitkeep file:
mkdir -p changelog && touch changelog/.gitkeep
First Change File:
Create a change file (e.g., changelog/feat-add-login.md) with metadata and content:
Significance: minor
Type: added
Comment: New login feature
Users can now log in via OAuth.
Validate:
composer exec -- changelogger validate changelog/feat-add-login.md
Generate Changelog:
composer exec -- changelogger write
composer.json: Configure extra.changelogger (e.g., changes-dir, types).CHANGELOG.md: Default output file (customizable via config).changelog/*.md: Change files for each PR.PR-Based Changelogging:
feat/login-oauth) to auto-generate filenames.- name: Validate Changelog
run: composer exec changelogger validate changelog/*.md
Release Process:
composer exec changelogger add --significance=minor --type=added --comment="New feature" --entry="Description"
composer exec changelogger write --version=1.2.0
git add CHANGELOG.md changelog/.gitkeep
Custom Types:
Extend types in composer.json for domain-specific categories:
"extra": {
"changelogger": {
"types": {
"deprecated": "Deprecated",
"security": "Security Fixes"
}
}
}
Artisan Command:
Create a custom command to wrap changelogger:
// app/Console/Commands/GenerateChangelog.php
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class GenerateChangelog extends Command {
protected $signature = 'changelog:generate {--version=}';
public function handle() {
$process = new Process(['changelogger', 'write', '--version=' . $this->option('version')]);
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
$this->info('Changelog generated!');
}
}
Register in app/Console/Kernel.php:
protected $commands = [
Commands\GenerateChangelog::class,
];
Git Hooks:
Use Laravel’s repository facade to trigger changelog updates post-merge:
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Process;
public function boot() {
Event::listen('repository.merged', function () {
Process::run('composer exec changelogger validate changelog/*.md');
});
}
Empty Entries:
[ ]).changelogger validate --strict.Version Bumps:
semver plugin may miscalculate if Significance is missing or invalid.--version flag to override:
composer exec changelogger write --version=1.0.0
Plugin Conflicts:
formatter or versioning plugins may break if not properly autoloaded.FormatterPlugin/VersioningPlugin and are PSR-4 compliant.Merge Conflicts:
changelog/feat-x.md) cause conflicts.changelog/feat-login-{branch-name}.md).Dry Runs:
Use --dry-run to preview changes:
composer exec changelogger write --dry-run
Verbose Output: Enable debug mode:
composer exec changelogger write -vvv
Custom Formatter:
Extend keepachangelog to support custom Markdown (e.g., tables):
// app/Plugins/CustomFormatter.php
namespace App\Plugins;
use Automattic\Jetpack\Changelogger\FormatterPlugin;
class CustomFormatter implements FormatterPlugin {
public function format(array $entries) {
// Custom logic (e.g., wrap entries in tables)
return "```markdown\n| Version | Changes |\n|---------|---------|\n" . implode("\n", $entries) . "\n```";
}
}
Register in composer.json:
"extra": {
"changelogger": {
"formatter": {
"class": "App\\Plugins\\CustomFormatter"
}
}
}
Git Metadata:
Auto-populate Comment with PR numbers using a Laravel service:
// app/Services/ChangelogService.php
use Illuminate\Support\Facades\Http;
class ChangelogService {
public function getPrNumber(string $branch) {
$response = Http::get("https://api.github.com/repos/{repo}/compare/{branch}...main");
return $response->object()->commit->parents[0]->message ?? null;
}
}
Hook into changelogger add via a custom script.
WordPress Versioning:
Use the wordpress plugin for decimal versions (e.g., 9.4):
composer exec changelogger write --point-release
changelog and changes-dir paths are relative to composer.json (not project root).Type field if types is empty in config (defaults to Keep a Changelog types).${new}/${old} in link-template for release notes:
"link-template": "https://github.com/{repo}/releases/tag/v${new}"
---
How can I help you explore Laravel packages today?