mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 10:37:30 -07:00
misc: Created cleanup script (for releases preparation) (#1833)
* misc: Created cleanup script (for releases preparation) * Update _cleanup.php * Update _cleanup.php * Update _cleanup.php
This commit is contained in:
parent
bc95e14be3
commit
68bf26d0f4
2 changed files with 81 additions and 1 deletions
5
.github/workflows/cd.yml
vendored
5
.github/workflows/cd.yml
vendored
|
@ -46,11 +46,14 @@ jobs:
|
|||
- name: Install Composer dependencies
|
||||
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Cleanup
|
||||
run: php _cleanup.php && rm _cleanup.php
|
||||
|
||||
- name: Create archive
|
||||
id: create-zip
|
||||
run: |
|
||||
ZIP_NAME="torrentpier-v${{ env.RELEASE_VERSION }}.zip"
|
||||
zip -r "$ZIP_NAME" . -x ".git/*" ".github/*"
|
||||
zip -r "$ZIP_NAME" . -x ".git/*"
|
||||
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Publish to GitHub
|
||||
|
|
77
_cleanup.php
Normal file
77
_cleanup.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/**
|
||||
* TorrentPier – Bull-powered BitTorrent tracker engine
|
||||
*
|
||||
* @copyright Copyright (c) 2005-2025 TorrentPier (https://torrentpier.com)
|
||||
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
|
||||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||||
*/
|
||||
|
||||
define('BB_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
|
||||
$items = [
|
||||
'.github',
|
||||
'.editorconfig',
|
||||
'.gitignore',
|
||||
'.styleci.yml',
|
||||
'CHANGELOG.md',
|
||||
'cliff.toml',
|
||||
'cliff-releases.toml',
|
||||
'CODE_OF_CONDUCT.md',
|
||||
'CONTRIBUTING.md',
|
||||
'crowdin.yml',
|
||||
'HISTORY.md',
|
||||
'README.md',
|
||||
'SECURITY.md'
|
||||
];
|
||||
|
||||
foreach ($items as $item) {
|
||||
$path = BB_ROOT . $item;
|
||||
|
||||
if (is_file($path)) {
|
||||
removeFile($path);
|
||||
} elseif (is_dir($path)) {
|
||||
removeDir($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove target file
|
||||
*
|
||||
* @param string $file Path to file
|
||||
*/
|
||||
function removeFile(string $file): void
|
||||
{
|
||||
if (unlink($file)) {
|
||||
echo "[INFO] File removed: $file" . PHP_EOL;
|
||||
} else {
|
||||
echo "[ERROR] 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 "[INFO] Folder removed: $dir" . PHP_EOL;
|
||||
} else {
|
||||
echo "[ERROR] Folder cannot be removed: $dir" . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue