misc(cliff): Added automated script for releases creation (#1930)

* misc(cliff): Added automated script for releases creation

* Updated

* Update functions_cli.php

* Updated

* Updated

* Update functions_cli.php

* Updated

* Update _release.php

* Update cliff.toml

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php

* Update _release.php
This commit is contained in:
Roman Kelesidis 2025-06-09 15:21:17 +03:00 committed by GitHub
commit 6adde35849
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 297 additions and 164 deletions

View file

@ -9,6 +9,7 @@
if (!defined('BB_ROOT')) {
define('BB_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
define('BB_PATH', BB_ROOT);
}
// Check CLI mode
@ -16,12 +17,21 @@ if (php_sapi_name() !== 'cli') {
exit;
}
if (!function_exists('removeFile')) {
// Get all constants
require_once BB_ROOT . 'library/defines.php';
// Include CLI functions
require INC_DIR . '/functions_cli.php';
}
$items = [
'.github',
'.cliffignore',
'.editorconfig',
'.gitignore',
'.styleci.yml',
'_release.php',
'CHANGELOG.md',
'cliff.toml',
'CODE_OF_CONDUCT.md',
@ -41,44 +51,3 @@ foreach ($items as $item) {
removeDir($path);
}
}
/**
* Remove target file
*
* @param string $file Path to file
*/
function removeFile(string $file): void
{
if (unlink($file)) {
echo "- File removed: $file" . PHP_EOL;
} else {
echo "- File cannot be removed: $file" . PHP_EOL;
exit;
}
}
/**
* Remove folder (recursively)
*
* @param string $dir Path to folder
*/
function removeDir(string $dir): void
{
$it = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file) {
if ($file->isDir()) {
removeDir($file->getPathname());
} else {
removeFile($file->getPathname());
}
}
if (rmdir($dir)) {
echo "- Folder removed: $dir" . PHP_EOL;
} else {
echo "- Folder cannot be removed: $dir" . PHP_EOL;
exit;
}
}