2022-06-16 19:44:07 +00:00
< ? php
/**
2022-07-21 22:58:23 +00:00
* Helper script for inserting NEXT_CHANGELOG contents into readme . txt .
2022-06-16 19:44:07 +00:00
*/
$now = time ();
if ( getenv ( 'TIME_OVERRIDE' ) ) {
$now = strtotime ( getenv ( 'TIME_OVERRIDE' ) );
}
$base_dir = dirname ( dirname ( dirname ( __DIR__ ) ) );
2023-02-20 05:00:14 +00:00
// The release date is 22 days after the code freeze.
$release_time = strtotime ( '+22 days' , $now );
2022-06-16 19:44:07 +00:00
$release_date = date ( 'Y-m-d' , $release_time );
$readme_file = $base_dir . '/plugins/woocommerce/readme.txt' ;
$next_log_file = $base_dir . '/plugins/woocommerce/NEXT_CHANGELOG.md' ;
$readme = file_get_contents ( $readme_file );
$next_log = file_get_contents ( $next_log_file );
$next_log = preg_replace ( " /= ( \ d+ \ . \ d+ \ . \ d+) YYYY-mm-dd =/ " , " = \\ 1 { $release_date } = " , $next_log );
2022-06-28 18:15:39 +00:00
// Convert PR number to markdown link.
$next_log = preg_replace ( " / \ [#( \ d+) \ ]/ " , '[#$1](https://github.com/woocommerce/woocommerce/pull/$1)' , $next_log );
2022-06-16 19:44:07 +00:00
$readme = preg_replace ( " /== Changelog == \n (.*?) \ [See changelog for all versions \ ]/s " , " == Changelog == \n \n { $next_log } \n \n [See changelog for all versions] " , $readme );
file_put_contents ( $readme_file , $readme );