-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8100 from kenjis/docs-update-RELEASE.md
docs: update RELEASE.md
- Loading branch information
Showing
6 changed files
with
192 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
function replace_file_content(string $path, string $pattern, string $replace): void | ||
{ | ||
$file = file_get_contents($path); | ||
$output = preg_replace($pattern, $replace, $file); | ||
file_put_contents($path, $output); | ||
} | ||
|
||
// Main. | ||
chdir(__DIR__ . '/..'); | ||
|
||
if ($argc !== 3) { | ||
echo "Usage: php {$argv[0]} <current_version> <new_version>" . PHP_EOL; | ||
echo "E.g.,: php {$argv[0]} 4.4.3 4.4.4" . PHP_EOL; | ||
|
||
exit(1); | ||
} | ||
|
||
// Gets version number from argument. | ||
$versionCurrent = $argv[1]; // e.g., '4.4.3' | ||
$versionCurrentParts = explode('.', $versionCurrent); | ||
$minorCurrent = $versionCurrentParts[0] . '.' . $versionCurrentParts[1]; | ||
$version = $argv[2]; // e.g., '4.4.4' | ||
$versionParts = explode('.', $version); | ||
$minor = $versionParts[0] . '.' . $versionParts[1]; | ||
$isMinorUpdate = ($minorCurrent !== $minor); | ||
|
||
// Creates a branch for release. | ||
system('git switch develop'); | ||
system('git switch -c docs-changelog-' . $version); | ||
system('git switch docs-changelog-' . $version); | ||
|
||
// Copy changelog | ||
$changelog = "./user_guide_src/source/changelogs/v{$version}.rst"; | ||
$changelogIndex = './user_guide_src/source/changelogs/index.rst'; | ||
if ($isMinorUpdate) { | ||
copy('./admin/next-changelog-minor.rst', $changelog); | ||
} else { | ||
copy('./admin/next-changelog-patch.rst', $changelog); | ||
} | ||
// Add changelog to index.rst. | ||
replace_file_content( | ||
$changelogIndex, | ||
'/\.\. toctree::\n :titlesonly:\n/u', | ||
".. toctree::\n :titlesonly:\n\n v{$version}" | ||
); | ||
// Replace {version} | ||
$length = mb_strlen("Version {$version}"); | ||
$underline = str_repeat('#', $length); | ||
replace_file_content( | ||
$changelog, | ||
'/#################\nVersion {version}\n#################/u', | ||
"{$underline}\nVersion {$version}\n{$underline}" | ||
); | ||
replace_file_content( | ||
$changelog, | ||
'/{version}/u', | ||
"{$version}" | ||
); | ||
|
||
// Copy upgrading | ||
$versionWithoutDots = str_replace('.', '', $version); | ||
$upgrading = "./user_guide_src/source/installation/upgrade_{$versionWithoutDots}.rst"; | ||
$upgradingIndex = './user_guide_src/source/installation/upgrading.rst'; | ||
copy('./admin/next-upgrading-guide.rst', $upgrading); | ||
// Add upgrading to upgrading.rst. | ||
replace_file_content( | ||
$upgradingIndex, | ||
'/ backward_compatibility_notes\n/u', | ||
" backward_compatibility_notes\n\n upgrade_{$versionWithoutDots}" | ||
); | ||
// Replace {version} | ||
$length = mb_strlen("Upgrading from {$versionCurrent} to {$version}"); | ||
$underline = str_repeat('#', $length); | ||
replace_file_content( | ||
$upgrading, | ||
'/##############################\nUpgrading from {version} to {version}\n##############################/u', | ||
"{$underline}\nUpgrading from {$versionCurrent} to {$version}\n{$underline}" | ||
); | ||
|
||
// Commits | ||
system("git add {$changelog} {$changelogIndex}"); | ||
system("git add {$upgrading} {$upgradingIndex}"); | ||
system('git commit -m "docs: add changelog and upgrade for v' . $version . '"'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
function replace_file_content(string $path, string $pattern, string $replace): void | ||
{ | ||
$file = file_get_contents($path); | ||
$output = preg_replace($pattern, $replace, $file); | ||
file_put_contents($path, $output); | ||
} | ||
|
||
// Main. | ||
chdir(__DIR__ . '/..'); | ||
|
||
if ($argc !== 2) { | ||
echo "Usage: php {$argv[0]} <version>" . PHP_EOL; | ||
echo "E.g.,: php {$argv[0]} 4.4.3" . PHP_EOL; | ||
|
||
exit(1); | ||
} | ||
|
||
// Gets version number from argument. | ||
$version = $argv[1]; // e.g., '4.4.3' | ||
$versionParts = explode('.', $version); | ||
$minor = $versionParts[0] . '.' . $versionParts[1]; | ||
|
||
// Creates a branch for release. | ||
system('git switch develop'); | ||
system('git switch -c release-' . $version); | ||
system('git switch docs-changelog-' . $version); | ||
|
||
// Updates version number in "CodeIgniter.php". | ||
replace_file_content( | ||
'./system/CodeIgniter.php', | ||
'/public const CI_VERSION = \'.*?\';/u', | ||
"public const CI_VERSION = '{$version}';" | ||
); | ||
|
||
// Updates version number in "conf.py". | ||
replace_file_content( | ||
'./user_guide_src/source/conf.py', | ||
'/^version = \'.*?\'/mu', | ||
"version = '{$minor}'" | ||
); | ||
replace_file_content( | ||
'./user_guide_src/source/conf.py', | ||
'/^release = \'.*?\'/mu', | ||
"release = '{$version}'" | ||
); | ||
|
||
// Updates release date in changelogs. | ||
$date = date('F j, Y'); | ||
replace_file_content( | ||
"./user_guide_src/source/changelogs/v{$version}.rst", | ||
'/^Release Date: .*/mu', | ||
"Release Date: {$date}" | ||
); | ||
|
||
// Commits | ||
system('git add -u'); | ||
system('git commit -m "Prep for ' . $version . ' release"'); |