Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 35 additions & 46 deletions build/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function usage(string $command)
echo PHP_TAB . PHP_TAB . '--remote=<remote>:' . PHP_TAB . 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;
echo PHP_TAB . PHP_TAB . '--exclude-zip:' . PHP_TAB . PHP_TAB . PHP_TAB . 'Exclude the generation of .zip packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--exclude-gzip:' . PHP_TAB . PHP_TAB . PHP_TAB . 'Exclude the generation of .tar.gz packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--exclude-bzip2:' . PHP_TAB . PHP_TAB . 'Exclude the generation of .tar.bz2 packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--include-zstd:' . PHP_TAB . PHP_TAB . PHP_TAB . 'Include the generation of .tar.zst packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--include-bzip2:' . PHP_TAB . PHP_TAB . 'Exclude the generation of .tar.bz2 packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--exclude-zstd:' . PHP_TAB . PHP_TAB . PHP_TAB . 'Include the generation of .tar.zst packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--disable-patch-packages:' . PHP_TAB . 'Disable the generation of patch packages' . PHP_EOL;
echo PHP_TAB . PHP_TAB . '--help:' . PHP_TAB . PHP_TAB . PHP_TAB . PHP_TAB . 'Show this help output' . PHP_EOL;
echo PHP_EOL;
Expand Down Expand Up @@ -237,8 +237,8 @@ function clean_composer(string $dir)
$remote = $options['remote'] ?? false;
$excludeZip = isset($options['exclude-zip']);
$excludeGzip = isset($options['exclude-gzip']);
$excludeBzip2 = isset($options['exclude-bzip2']);
$excludeZstd = !isset($options['include-zstd']);
$excludeBzip2 = !isset($options['include-bzip2']);
$excludeZstd = isset($options['exclude-zstd']);
$buildPatchPackages = false && !isset($options['disable-patch-packages']);
$showHelp = isset($options['help']);

Expand Down Expand Up @@ -332,9 +332,10 @@ function clean_composer(string $dir)
require_once $fullpath . '/libraries/src/Version.php';

// Set version information for the build
$version = Version::MAJOR_VERSION . '.' . Version::MINOR_VERSION;
$release = Version::PATCH_VERSION;
$fullVersion = (new Version())->getShortVersion();
$majorVersion = Version::MAJOR_VERSION;
$version = Version::MAJOR_VERSION . '.' . Version::MINOR_VERSION;
$release = Version::PATCH_VERSION;
$fullVersion = (new Version())->getShortVersion();

$previousRelease = Version::PATCH_VERSION - 1;

Expand Down Expand Up @@ -541,10 +542,12 @@ function clean_composer(string $dir)
$fromName = $num == 0 ? 'x' : $num;

// Create the diff archive packages using the file name list.
if (!$excludeBzip2) {
$packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.bz2';
if (!$excludeZip) {
$packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.zip';
echo "Building " . $packageName . "... ";
system('tar --create --bzip2 --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null');
chdir($time);
system('zip ../packages/' . $packageName . ' -@ < ../diffconvert/' . $version . '.' . $num . '> /dev/null');
chdir('..');
echo "done.\n";
$checksums[$packageName] = [];
}
Expand All @@ -557,20 +560,18 @@ function clean_composer(string $dir)
$checksums[$packageName] = [];
}

if (!$excludeZip) {
$packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.zip';
if (!$excludeBzip2) {
$packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.bz2';
echo "Building " . $packageName . "... ";
chdir($time);
system('zip ../packages/' . $packageName . ' -@ < ../diffconvert/' . $version . '.' . $num . '> /dev/null');
chdir('..');
system('tar --create --bzip2 --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}

if (!$excludeZstd) {
$packageName = 'Joomla_' . $version . '.' . $fromName . '_to_' . $fullVersion . '-' . $packageStability . '-Patch_Package.tar.zst';
echo "Building " . $packageName . "... ";
system('tar --create --use-compress-program=zstd --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null');
system('tar "-I zstd --ultra -22" --create --no-recursion --directory ' . $time . ' --file packages/' . $packageName . ' --files-from diffconvert/' . $version . '.' . $num . '> /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
Expand All @@ -580,10 +581,10 @@ function clean_composer(string $dir)
chdir($time);

// Create full archive packages.
if (!$excludeBzip2) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.bz2';
if (!$excludeZip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.zip';
echo "Building " . $packageName . "... ";
system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null');
system('zip -r ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
Expand All @@ -596,18 +597,18 @@ function clean_composer(string $dir)
$checksums[$packageName] = [];
}

if (!$excludeZip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.zip';
if (!$excludeBzip2) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.bz2';
echo "Building " . $packageName . "... ";
system('zip -r ../packages/' . $packageName . ' * > /dev/null');
system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}

if (!$excludeZstd) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Full_Package.tar.zst';
echo "Building " . $packageName . "... ";
system('tar --create --use-compress-program=zstd --file ../packages/' . $packageName . ' * > /dev/null');
system('tar "-I zstd --ultra -22" --create --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
Expand All @@ -622,10 +623,10 @@ function clean_composer(string $dir)
system('rm images/joomla_black.png');
system('rm images/powered_by.png');

if (!$excludeBzip2) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.bz2';
if (!$excludeZip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.zip';
echo "Building " . $packageName . "... ";
system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null');
system('zip -r ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
Expand All @@ -638,18 +639,18 @@ function clean_composer(string $dir)
$checksums[$packageName] = [];
}

if (!$excludeZip) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.zip';
if (!$excludeBzip2) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.bz2';
echo "Building " . $packageName . "... ";
system('zip -r ../packages/' . $packageName . ' * > /dev/null');
system('tar --create --bzip2 --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}

if (!$excludeZstd) {
$packageName = 'Joomla_' . $fullVersion . '-' . $packageStability . '-Update_Package.tar.zst';
echo "Building " . $packageName . "... ";
system('tar --create --use-compress-program=zstd --file ../packages/' . $packageName . ' * > /dev/null');
system('tar "-I zstd --ultra -22" --create --file ../packages/' . $packageName . ' * > /dev/null');
echo "done.\n";
$checksums[$packageName] = [];
}
Expand Down Expand Up @@ -689,18 +690,13 @@ function clean_composer(string $dir)
echo "Generating github_release.txt file\n";

$githubContent = [];
$githubText = '';
$releaseText = [
'FULL' => 'New Joomla! Installations ',
'POINT' => 'Update from Joomla! ' . $version . '.' . $previousRelease . ' ',
'MINOR' => 'Update from Joomla! ' . $version . '.x ',
'UPGRADE' => 'Update from Joomla! 3.10 ',
];

if (!$buildPatchPackages) {
$releaseText['UPGRADE'] = 'Update from a previous version of Joomla! ';
}

$githubLink = 'https://github.com/joomla/joomla-cms/releases/download/' . $tagVersion . '/';

foreach ($checksums as $packageName => $packageHashes) {
Expand All @@ -718,19 +714,12 @@ function clean_composer(string $dir)
$type = 'UPGRADE';
}

$githubContent[$type][] = '[' . substr($packageName, strpos($packageName, 'Package') + 7) . '](' . $githubLink . $packageName . ')';
$githubContent[$type][$packageName] = $packageHashes;
}

foreach ($releaseText as $type => $text) {
if (empty($githubContent[$type])) {
continue;
}

$githubText .= $text;
$githubText .= implode(" | ", $githubContent[$type]);

$githubText .= "\n";
}
ob_start();
require __DIR__ . '/layouts/github.php';
$githubText = ob_get_clean();

file_put_contents('github_release.txt', $githubText);
}
Expand Down
115 changes: 115 additions & 0 deletions build/layouts/github.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

$version = $version ?? '5.0.0'; // set in the build script by extracting it from the Version class
$majorVersion = $majorVersion ?? substr($version, 0, strpos($version, '.'));
$previousVersion = $previousRelease ?? '4.4.0'; // Last patch release
$previousMajorVersion = substr($previousVersion, 0, strpos($previousVersion, '.'));
$previousMajorMinorVersion = $previousMajorVersion . '.4';
$tagVersion = $tagVersion ?? $version; // Set in the build script by extracting it from git
$githubContent = $githubContent ?? []; // set by build script

$contributors = 'INSERT_HERE';
$pullRequests = 'INSERT_HERE';
$migrationInfo = '[New migration guide](https://manual.joomla.org/migrations/44-50/)';
$documentation = 'New developer [documentation](https://manual.joomla.org)';
$releasePage = 'https://www.joomla.org/announcements/release-news/5900-joomla-5-0-and-joomla-4-4-are-here';
$releaseDownloadPage = 'https://downloads.joomla.org/cms/joomla' . $majorVersion;
$changelog = 'https://github.com/joomla/joomla-cms/compare/' . $previousVersion .'...' . $tagVersion;
$githubDownloadLink = 'https://github.com/joomla/joomla-cms/releases/download/' . $tagVersion . '/';

$table = [];

foreach (['FULL', 'UPGRADE', 'MINOR', 'POINT'] as $type) {
if (empty($githubContent[$type])) {
continue;
}

$table[$type] = '';
foreach($githubContent[$type] as $packageName => $hashes) {
if (str_ends_with($packageName, '.zip')) {
$table[$type] .= "| [ZIP Archive (.zip)]";
} else if (str_ends_with($packageName, '.tar.gz')) {
$table[$type] .= "| [GNU Zip Archive (.tar.gz)]";
} else if (str_ends_with($packageName, '.tar.bz2')) {
$table[$type] .= "| [Bzip2 Archive (.tar.zst)]";
} else if (str_ends_with($packageName, '.tar.zst')) {
$table[$type] .= "| [Zstandard Archive (.tar.zst)]";
} else {
// Unknown file types
continue;
}
$table[$type] .= "({$githubDownloadLink}{$packageName}) | `" . $hashes['sha256'] . "` |\n";
}
}

$echo = function($item) use ($table) {
return $table[$item] ?? '';
};


// Release Information
$output = <<<MD

## 👀 Release information
* 💁 **{$contributors}**+ contributors
* 🧰 **{$pullRequests}**+ Pull Requests has been merged
* ⬆️ {$migrationInfo}
* 📖 {$documentation}
* 🌎 [Release page]({$releasePage})
* 👀 [Full Changelog]({$changelog})

MD;

// Download Information
$output .= <<<MD

## 🚀 Download information
> [!NOTE]
> Userfacing information about this Joomla! release can be found on the [release page]({$releasePage})

MD;

// Installation Packages
if (!empty($table['FULL'])):

$output .= <<<MD

### 🔥 Installation Packages

| New Joomla! Installations | SHA-256 Checksums |
|---------------------------|-------------------|
{$echo('FULL')}
> Additional and a second source of checksums can be found at our official [download page]({$releaseDownloadPage}). If you need further information on how to validate a release package please visit our [documentation](https://docs.joomla.org/How_to_determine_a_package_checksum).

MD;

endif;

// Update Packages
if (!empty($table['UPGRADE'])):

$output .= <<<MD

### ✒️ Upgrade Packages

> [!IMPORTANT]
> Don't update directly from a version lower than 4.4 it is important that you first update to 4.4 and then update to 5.x

| Update from a previous version | SHA-256 Checksums |
|--------------------------------|-------------------|
{$echo('UPGRADE')}
> Additional and a second source of checksums can be found at our official [download page]({$releaseDownloadPage}). If you need further information on how to validate a release package please visit our [documentation](https://docs.joomla.org/How_to_determine_a_package_checksum).

MD;
endif;

// Github autogenerated content, icon tempaltes
$output .= <<<MD

## 💆 New Contributors

## 🧹 What has been changed

MD;

echo $output;