wishthis/vendor/marcocesarato/php-conventional-changelog/.changelog

53 lines
1.8 KiB
Text
Raw Permalink Normal View History

<?php
namespace ConventionalChangelog;
use ConventionalChangelog\Git\Repository;
use ConventionalChangelog\Helper\SemanticVersion;
$releaseMessagePrefix = 'chore(release): ';
return [
'types' => ['feat', 'fix', 'perf', 'docs', 'chore'],
// Ignore changelogs
'ignorePatterns' => [
'/' . preg_quote($releaseMessagePrefix, '/') . '.*/i',
'/chore\(changelog\)[:].*/i',
],
'releaseCommitMessageFormat' => "{$releaseMessagePrefix}{{currentTag}}",
'postRun' => function () use ($releaseMessagePrefix) {
$lastTag = Repository::getLastTagRefname();
$lastTagCommit = Repository::getLastTagRefnameCommit();
$lastCommit = Repository::getLastCommit();
if ($lastTagCommit !== $lastCommit) {
return;
}
$binFile = __DIR__ . '/conventional-changelog';
$readmeFile = __DIR__ . '/README.md';
$semverRegex = SemanticVersion::PATTERN;
// Get version
$version = new SemanticVersion($lastTag);
// Update version on readme
$readme = file_get_contents($readmeFile);
$readme = preg_replace("/(https:\/\/img\.shields\.io\/badge\/version)-({$semverRegex})-/m", '$1-' . $version->getVersion() . '-', $readme);
file_put_contents($readmeFile, $readme);
// Update version on bin
$bin = file_get_contents($binFile);
$bin = preg_replace("/(\('conventional-changelog', )'({$semverRegex})'/m", '$1\'' . $version->getVersion() . '\'', $bin);
file_put_contents($binFile, $bin);
// Delete tag
Repository::deleteTag($lastTag);
// Commit and tag
$message = $releaseMessagePrefix . $version->getVersion();
Repository::commit($message, [$binFile, $readmeFile], true, true, true);
Repository::tag($lastTag);
},
];