Created
March 22, 2023 06:33
-
-
Save franck-paul/2f799582a01393eb3c2b078d82b75e88 to your computer and use it in GitHub Desktop.
Récupération version du module et version Dotclear minimale si existante dans le fichier dcstore.xml
This file contains hidden or 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
<?php | |
$version = ''; | |
$dcmin = '2.0'; | |
if (file_exists('dcstore.xml')) { | |
if (file_exists('src/Define.php')) { | |
$df = file_get_contents('src/Define.php'); | |
if (preg_match('/\$this-\>version(?:\s*?)=(?:\s.?)[\'\"](.*?)[\'\"]/s', $df, $matches)) { | |
if (isset($matches[1])) { | |
$version = $matches[1]; | |
} | |
} | |
if (preg_match('/\$this-\>require(?:\s*?)=(?:\s.?)\[(?:.*?)[\'\"]core[\'\"](?:.*?),(?:.*?)[\'\"](.*?)[\'\"](?:.*?)\]/s', $df, $matches)) { | |
if (isset($matches[1])) { | |
$dcmin = $matches[1]; | |
} | |
} | |
} elseif (file_exists('./_define.php')) { | |
$df = file_get_contents('./_define.php'); | |
if (preg_match('/registerModule\((.*?),(.*?)[\'\"],(.*?)[\'\"],(.*?)[\'\"](.*?)[\'\"](.*?)(,.*)\)/s', $df, $matches)) { | |
if (isset($matches[5])) { | |
$version = $matches[5]; | |
if (isset($matches[7])) { | |
$str = $matches[7]; | |
if (preg_match('/\[(.*?)[\'\"]core[\'\"](.*?),(.*?)[\'\"](.*?)[\'\"](.*?)\]/s', $str, $submatches)) { | |
$dcmin = $submatches[4]; | |
} | |
} | |
} | |
} | |
} | |
if ($version !== '') { | |
$ds = file_get_contents('dcstore.xml'); | |
if ($ds) { | |
$ds = preg_replace('/<version>(.*?)<\/version>/s', "<version>$version</version>", $ds); | |
$ds = preg_replace('/download\/(.*?)\//s', "download/$version/", $ds); | |
$ds = preg_replace('/(.*)-(.*?).zip/s', "$1-$version.zip", $ds); | |
$ds = preg_replace('/<da:dcmin>(.*?)<\/da:dcmin>/s', "<da:dcmin>$dcmin</da:dcmin>", $ds); | |
if ($ds) { | |
file_put_contents('dcstore.xml', $ds); | |
} | |
} | |
} | |
} | |
echo "::set-output name=module_version::$version\n"; | |
echo "::set-output name=module_dcmin::$dcmin\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment