Updated release tooling

This commit is contained in:
Simon Wisselink
2024-02-26 14:55:24 +01:00
parent 29dd621b53
commit ee58a2173b
4 changed files with 56 additions and 2 deletions

0
changelog/.gitkeep Normal file
View File

View File

@ -8,8 +8,9 @@ else
fi
git checkout -b "release/$1"
sed -i "s/## \\[Unreleased\\]/## \\[Unreleased\\]\\n\\n## \\[$1\\] - $(date +%Y-%m-%d)/" CHANGELOG.md
sed -i "s/const SMARTY_VERSION = '[^']\+';/const SMARTY_VERSION = '$1';/" libs/Smarty.class.php
php utilities/update-changelog.php $1
php utilities/update-smarty-version-number.php $1
git add CHANGELOG.md libs/Smarty.class.php
git commit -m "version bump"

View File

@ -0,0 +1,42 @@
<?php
// This takes the *.md files in changelog/ dir and inserts them
// right below the '## [Unreleased]' marker in CHANGELOG.md
$path_to_main_changelog = 'CHANGELOG.md';
$marker = '## [Unreleased]';
$changelog_files_pattern = 'changelog/*.md';
$new_version = $argv[1];
$file_contents = file_get_contents($path_to_main_changelog);
foreach (glob($changelog_files_pattern) as $filename) {
$content_to_insert = file_get_contents($filename);
if (!endsWithNewline($content_to_insert)) {
$content_to_insert .= "\n";
}
$file_contents = str_replace(
$marker,
$marker . $content_to_insert,
$file_contents
);
unlink($filename);
}
// add the version number and date
$file_contents = str_replace(
$marker,
$marker . sprintf("\n\n## [%s] - %s\n", $new_version, date('Y-m-d')),
$file_contents
);
file_put_contents($path_to_main_changelog, $file_contents);
function endsWithNewline($str): bool
{
return preg_match('/[\r\n]$/', $str) === 1;
}

View File

@ -0,0 +1,11 @@
<?php
// This takes the Smarty class file and updates the SMARTY_VERSION constant
$path_to_smarty_class = 'libs/Smarty.class.php';
$pattern = "/const SMARTY_VERSION = '[^']+'/";
$replacement = "const SMARTY_VERSION = '" . $argv[1] . "'";
$file_contents = preg_replace($pattern, $replacement, file_get_contents($path_to_smarty_class));
file_put_contents($path_to_smarty_class, $file_contents);