mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Also release a tar.gz
This commit is contained in:
parent
1d32f26add
commit
9e167ac981
1 changed files with 42 additions and 15 deletions
53
release.php
53
release.php
|
|
@ -1,48 +1,75 @@
|
||||||
<?php
|
<?php
|
||||||
chdir(__DIR__);
|
chdir(__DIR__);
|
||||||
|
|
||||||
$gulp = trim(`which gulp`);
|
$gulp = trim(`which gulp`);
|
||||||
if (!$gulp) {
|
if (!$gulp) {
|
||||||
exit('gulp not installed, run as root: npm install --global gulp-cli');
|
exit('gulp not installed, run as root: npm install --global gulp-cli');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$package = json_decode(file_get_contents('package.json'));
|
||||||
|
|
||||||
|
$zip_destination = "rainloop-{$package->version}.zip";
|
||||||
|
$tar_destination = "rainloop-{$package->version}.tar";
|
||||||
|
|
||||||
|
@unlink($zip_destination);
|
||||||
|
@unlink($tar_destination);
|
||||||
|
@unlink("{$tar_destination}.gz");
|
||||||
|
|
||||||
passthru($gulp, $return_var);
|
passthru($gulp, $return_var);
|
||||||
if ($return_var) {
|
if ($return_var) {
|
||||||
exit("gulp failed with error code {$return_var}\n");
|
exit("gulp failed with error code {$return_var}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
$package = json_decode(file_get_contents('package.json'));
|
// Temporary rename folder to speed up PharData
|
||||||
|
if (!rename('rainloop/v/0.0.0', "rainloop/v/{$package->version}")){
|
||||||
$destination = "rainloop-{$package->version}.zip";
|
exit('Failed to temporary rename rainloop/v/0.0.0');
|
||||||
|
}
|
||||||
|
register_shutdown_function(function(){
|
||||||
|
// Rename folder back to original
|
||||||
|
@rename("rainloop/v/{$GLOBALS['package']->version}", 'rainloop/v/0.0.0');
|
||||||
|
});
|
||||||
|
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
|
if (!$zip->open($zip_destination, ZIPARCHIVE::CREATE)) {
|
||||||
exit("Failed to create {$destination}");
|
exit("Failed to create {$zip_destination}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tar = new PharData($tar_destination);
|
||||||
|
|
||||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('rainloop/v'), RecursiveIteratorIterator::SELF_FIRST);
|
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('rainloop/v'), RecursiveIteratorIterator::SELF_FIRST);
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$file = str_replace('\\', '/', $file);
|
$file = str_replace('\\', '/', $file);
|
||||||
|
echo "{$file}\n";
|
||||||
// Ignore "." and ".." folders
|
// Ignore "." and ".." folders
|
||||||
if (in_array(substr($file, strrpos($file, '/')+1), array('.', '..')))
|
if (!in_array(substr($file, strrpos($file, '/')+1), array('.', '..'))) {
|
||||||
continue;
|
|
||||||
|
|
||||||
$dest = str_replace('/0.0.0', "/{$package->version}", $file);
|
|
||||||
if (is_dir($file)) {
|
if (is_dir($file)) {
|
||||||
$zip->addEmptyDir($dest);
|
$zip->addEmptyDir($file);
|
||||||
} else if (is_file($file)) {
|
} else if (is_file($file)) {
|
||||||
$zip->addFromString($dest, file_get_contents($file));
|
$zip->addFile($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tar->buildFromDirectory('./', "@rainloop/v/{$package->version}@");
|
||||||
|
|
||||||
$zip->addFromString('data/VERSION', $package->version);
|
$zip->addFromString('data/VERSION', $package->version);
|
||||||
|
$tar->addFromString('data/VERSION', $package->version);
|
||||||
|
|
||||||
//$zip->addFromString('data/EMPTY', $package->version);
|
//$zip->addFromString('data/EMPTY', $package->version);
|
||||||
|
//$tar->addFromString('data/EMPTY', $package->version);
|
||||||
|
|
||||||
$zip->addFile('_include.php');
|
$zip->addFile('_include.php');
|
||||||
|
$tar->addFile('_include.php');
|
||||||
|
|
||||||
$index = file_get_contents('index.php');
|
$index = file_get_contents('index.php');
|
||||||
$index = str_replace('0.0.0', $package->version, $index);
|
$index = str_replace('0.0.0', $package->version, $index);
|
||||||
$index = str_replace('source', 'community', $index);
|
$index = str_replace('source', 'community', $index);
|
||||||
$zip->addFromString('index.php', $index);
|
$zip->addFromString('index.php', $index);
|
||||||
|
$tar->addFromString('index.php', $index);
|
||||||
|
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|
||||||
echo "\n{$destination} created\n";
|
$tar->compress(Phar::GZ);
|
||||||
|
unlink($tar_destination);
|
||||||
|
|
||||||
|
echo "\n{$zip_destination} created\n{$tar_destination}.gz created\n";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue