@@ -28,7 +28,7 @@ function usage(string $command)
2828{
2929 echo PHP_EOL ;
3030 echo 'Usage: php ' . $ command . ' [options] ' . PHP_EOL ;
31- echo PHP_TAB . '[options]: ' . PHP_EOL ;
31+ echo PHP_TAB . '[options]: ' . PHP_EOL ;
3232 echo PHP_TAB . PHP_TAB . '--remote=<remote>: ' . PHP_TAB . 'The git remote reference to build from (ex: `tags/3.8.6`, `4.0-dev`), defaults to the most recent tag for the repository ' . PHP_EOL ;
3333 echo PHP_TAB . PHP_TAB . '--exclude-zip: ' . PHP_TAB . PHP_TAB . 'Exclude the generation of .zip packages ' . PHP_EOL ;
3434 echo PHP_TAB . PHP_TAB . '--exclude-gzip: ' . PHP_TAB . PHP_TAB . 'Exclude the generation of .tar.gz packages ' . PHP_EOL ;
@@ -211,6 +211,9 @@ function clean_composer(string $dir)
211211$ excludeZstd = !isset ($ options ['include-zstd ' ]);
212212$ showHelp = isset ($ options ['help ' ]);
213213
214+ // Disable the generation of extra text files
215+ $ includeExtraTextfiles = false ;
216+
214217if ($ showHelp )
215218{
216219 usage ($ argv [0 ]);
@@ -224,6 +227,9 @@ function clean_composer(string $dir)
224227 $ tagVersion = system ($ systemGit . ' describe --tags ` ' . $ systemGit . ' rev-list --tags --max-count=1` ' , $ tagVersion );
225228 $ remote = 'tags/ ' . $ tagVersion ;
226229 chdir ($ here );
230+
231+ // We are in release mode so we need the extra text files
232+ $ includeExtraTextfiles = true ;
227233}
228234
229235echo "Start build for remote $ remote. \n" ;
@@ -427,18 +433,21 @@ function clean_composer(string $dir)
427433 // Loop through and add all files except: tests, installation, build, .git, .travis, travis, phpunit, .md, or images
428434 foreach ($ files as $ file )
429435 {
430- if (substr ($ file , 0 , 1 ) === 'R ' ) {
431- $ fileName = substr ($ file , strrpos ($ file , "\t" ) + 1 );
432- } else {
433- $ fileName = substr ($ file , 2 );
436+ if (substr ($ file , 0 , 1 ) === 'R ' )
437+ {
438+ $ fileName = substr ($ file , strrpos ($ file , "\t" ) + 1 );
439+ }
440+ else
441+ {
442+ $ fileName = substr ($ file , 2 );
434443 }
435- $ folderPath = explode ('/ ' , $ fileName );
436- $ baseFolderName = $ folderPath [0 ];
437444
438- $ doNotPackageFile = in_array (trim ($ fileName ), $ doNotPackage );
439- $ doNotPatchFile = in_array (trim ($ fileName ), $ doNotPatch );
445+ $ folderPath = explode ('/ ' , $ fileName );
446+ $ baseFolderName = $ folderPath [0 ];
447+ $ doNotPackageFile = in_array (trim ($ fileName ), $ doNotPackage );
448+ $ doNotPatchFile = in_array (trim ($ fileName ), $ doNotPatch );
440449 $ doNotPackageBaseFolder = in_array ($ baseFolderName , $ doNotPackage );
441- $ doNotPatchBaseFolder = in_array ($ baseFolderName , $ doNotPatch );
450+ $ doNotPatchBaseFolder = in_array ($ baseFolderName , $ doNotPatch );
442451
443452 if ($ doNotPackageFile || $ doNotPatchFile || $ doNotPackageBaseFolder || $ doNotPatchBaseFolder )
444453 {
@@ -619,84 +628,98 @@ function clean_composer(string $dir)
619628
620629chdir ('.. ' );
621630
622- foreach (array_keys ($ checksums ) as $ packageName )
631+ // Thats only needed when we release a version
632+ if ($ includeExtraTextfiles )
623633{
624- echo "Generating checksums for $ packageName \n" ;
625634
626- foreach (array ( ' md5 ' , ' sha1 ' , ' sha256 ' , ' sha384 ' , ' sha512 ' ) as $ hash )
635+ foreach (array_keys ( $ checksums ) as $ packageName )
627636 {
628- if (file_exists ('packages/ ' . $ packageName ))
629- {
630- $ checksums [$ packageName ][$ hash ] = hash_file ($ hash , 'packages/ ' . $ packageName );
631- }
632- else
637+ echo "Generating checksums for $ packageName \n" ;
638+
639+ foreach (array ('sha256 ' , 'sha384 ' , 'sha512 ' ) as $ hash )
633640 {
634- echo "Package $ packageName not found in build directories \n" ;
641+ if (file_exists ('packages/ ' . $ packageName ))
642+ {
643+ $ checksums [$ packageName ][$ hash ] = hash_file ($ hash , 'packages/ ' . $ packageName );
644+ }
645+ else
646+ {
647+ echo "Package $ packageName not found in build directories \n" ;
648+ }
635649 }
636650 }
637- }
638-
639- echo "Generating checksums.txt file \n" ;
640651
641- $ checksumsContent = '' ;
652+ echo " Generating checksums.txt file \n" ;
642653
643- foreach ($ checksums as $ packageName => $ packageHashes )
644- {
645- $ checksumsContent .= "Filename: $ packageName \n" ;
654+ $ checksumsContent = '' ;
646655
647- foreach ($ packageHashes as $ hashType => $ hash )
656+ foreach ($ checksums as $ packageName => $ packageHashes )
648657 {
649- $ checksumsContent .= "$ hashType: $ hash \n" ;
650- }
658+ $ checksumsContent .= "Filename: $ packageName \n" ;
651659
652- $ checksumsContent .= "\n" ;
653- }
660+ foreach ($ packageHashes as $ hashType => $ hash )
661+ {
662+ $ checksumsContent .= "$ hashType: $ hash \n" ;
663+ }
654664
655- file_put_contents ('checksums.txt ' , $ checksumsContent );
665+ $ checksumsContent .= "\n" ;
666+ }
656667
657- echo " Generating github_release .txt file \n" ;
668+ file_put_contents ( ' checksums .txt' , $ checksumsContent ) ;
658669
659- $ githubContent = array ();
660- $ githubText = '' ;
661- $ releaseText = array (
662- 'FULL ' => 'New Joomla! Installations ' ,
663- 'POINT ' => 'Update from Joomla! ' . $ version . '. ' . $ previousRelease . ' ' ,
664- 'MINOR ' => 'Update from Joomla! ' . $ version . '.x ' ,
665- 'UPGRADE ' => 'Update from Joomla! 3.10 ' ,
666- );
667- $ githubLink = 'https://github.com/joomla/joomla-cms/releases/download/ ' . $ tagVersion . '/ ' ;
670+ echo "Generating github_release.txt file \n" ;
668671
669- foreach ($ checksums as $ packageName => $ packageHashes )
670- {
671- $ type = '' ;
672- if (strpos ($ packageName , 'Full_Package ' ) !== false )
672+ $ githubContent = array ();
673+ $ githubText = '' ;
674+ $ releaseText = array (
675+ 'FULL ' => 'New Joomla! Installations ' ,
676+ 'POINT ' => 'Update from Joomla! ' . $ version . '. ' . $ previousRelease . ' ' ,
677+ 'MINOR ' => 'Update from Joomla! ' . $ version . '.x ' ,
678+ 'UPGRADE ' => 'Update from Joomla! 3.10 ' ,
679+ );
680+ $ githubLink = 'https://github.com/joomla/joomla-cms/releases/download/ ' . $ tagVersion . '/ ' ;
681+
682+ foreach ($ checksums as $ packageName => $ packageHashes )
673683 {
674- $ type = 'FULL ' ;
675- } elseif (strpos ($ packageName , 'Patch_Package ' ) !== false ) {
676- if (strpos ($ packageName , '.x_to ' ) !== false ) {
677- $ type = 'MINOR ' ;
678- } else {
679- $ type = 'POINT ' ;
684+ $ type = '' ;
685+
686+ if (strpos ($ packageName , 'Full_Package ' ) !== false )
687+ {
688+ $ type = 'FULL ' ;
689+ }
690+ elseif (strpos ($ packageName , 'Patch_Package ' ) !== false )
691+ {
692+ if (strpos ($ packageName , '.x_to ' ) !== false )
693+ {
694+ $ type = 'MINOR ' ;
695+ }
696+ else
697+ {
698+ $ type = 'POINT ' ;
699+ }
700+ }
701+ elseif (strpos ($ packageName , 'Update_Package ' ) !== false )
702+ {
703+ $ type = 'UPGRADE ' ;
680704 }
681- } elseif ( strpos ( $ packageName , ' Update_Package ' ) !== false ) {
682- $ type = 'UPGRADE ' ;
705+
706+ $ githubContent [ $ type][] = '[ ' . substr ( $ packageName , strpos ( $ packageName , ' Package ' ) + 7 ) . ' ]( ' . $ githubLink . $ packageName . ' ) ' ;
683707 }
684708
685- $ githubContent [$ type ][] = '[ ' . substr ($ packageName , strpos ($ packageName , 'Package ' ) + 7 ) . ']( ' . $ githubLink . $ packageName . ') ' ;
686- }
709+ foreach ($ releaseText as $ type => $ text )
710+ {
711+ if (empty ($ githubContent [$ type ]))
712+ {
713+ continue ;
714+ }
687715
688- foreach ($ releaseText as $ type => $ text )
689- {
690- if (empty ($ githubContent [$ type ])) {
691- continue ;
692- }
716+ $ githubText .= $ text ;
717+ $ githubText .= implode (" | " , $ githubContent [$ type ]);
693718
694- $ githubText .= $ text ;
695- $ githubText .= implode ( " | " , $ githubContent [ $ type ]);
719+ $ githubText .= "\n" ;
720+ }
696721
697- $ githubText .= "\n" ;
722+ file_put_contents ( ' github_release.txt ' , $ githubText ) ;
698723}
699724
700- file_put_contents ('github_release.txt ' , $ githubText );
701-
702725echo "Build of version $ fullVersion complete! \n" ;
0 commit comments