mirror of
https://github.com/smarty-php/smarty.git
synced 2025-07-31 08:27:14 +02:00
Updated release tooling
This commit is contained in:
0
changelog/.gitkeep
Normal file
0
changelog/.gitkeep
Normal file
@ -8,8 +8,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout -b "release/$1"
|
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 add CHANGELOG.md libs/Smarty.class.php
|
||||||
git commit -m "version bump"
|
git commit -m "version bump"
|
||||||
|
42
utilities/update-changelog.php
Normal file
42
utilities/update-changelog.php
Normal 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;
|
||||||
|
}
|
11
utilities/update-smarty-version-number.php
Normal file
11
utilities/update-smarty-version-number.php
Normal 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);
|
Reference in New Issue
Block a user