Skip to content

Commit

Permalink
Merge pull request #1061 from nextcloud-releases/feat/improve_builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Altahrim authored May 29, 2024
2 parents 8ed1a9c + f1fbed3 commit 875e78d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config/config.php: config/major_versions.json config/releases.json $(wildcard config/enterprise_releases.json)
config/config.php: config/major_versions.json config/releases.json $(wildcard config/enterprise_*.json)
@echo '🏗 Build configuration file $(@)…'
build/config_builder > $(@)

Expand Down
15 changes: 11 additions & 4 deletions build/config_builder
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ $majorVersions = loadJson('major_versions');
$releases = loadJson('releases');

try {
$enterpriseReleases = loadJson('enterprise');
$enterpriseMajorVersions = loadJson('enterprise_major_versions');
$enterpriseReleases = loadJson('enterprise_releases');
foreach($majorVersions as $name => $version) {
if (isset($enterpriseMajorVersions[$name])) {
$majorVersions[$name] = array_merge($version, $enterpriseMajorVersions[$name]);
}
}
$majorVersions = array_replace_recursive($majorVersions + $enterpriseMajorVersions);
$releases = array_merge($releases, $enterpriseReleases);
$latestReleases = $generatedConfig = ['enterprise' => [], 'stable' => [], 'beta' => []];
} catch (\Exception) {
Expand All @@ -32,16 +39,15 @@ foreach ($releases as $releaseName => $info) {
}

// Generate previous configuration
$now = date('Y-m');
foreach ($releases as $releaseName => $info) {
preg_match('/(\d+)\.(\d+).(\d+)(?: (.+))?/A', $releaseName, $matches);
[, $major, $minor, $patch] = $matches;
$stability = getStabilityFromName($releaseName);
$isEol = isset($majorVersions[$major]['eol']) ? ($majorVersions[$major]['eol'] < $now) : false;
$isEol = isEol($releaseName, $majorVersions[$major]);
$generatedConfig[$stability][$major]['100'] = [
'latest' => $releaseName,
'internalVersion' => $info['internalVersion'],
'downloadUrl' => buildDownloadUrl($releaseName, $info),
'downloadUrl' => buildDownloadUrl($releaseName, $info, $majorVersions[$major]),
'web' => sprintf($docUrl, $major),
'eol' => $isEol,
'minPHPVersion' => $majorVersions[$major]['minPHP'] ?? '',
Expand Down Expand Up @@ -75,6 +81,7 @@ foreach($generatedConfig as $stability => $ignored) {

// Daily updates
$maxMajor = (int) max(array_keys($majorVersions));
$now = date('Y-m');
foreach ($majorVersions as $majorVersion => $info) {
if ($majorVersion < 20) {
break;
Expand Down
19 changes: 17 additions & 2 deletions build/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ function displayAsFile(array $generatedConfig) {
echo ';',PHP_EOL;
}

function buildDownloadUrl(string $releaseName, array $info): string {
function buildDownloadUrl(string $releaseName, array $info, array $majorVersion): string {
if (function_exists('buildEnterpriseDownloadUrl')) {
$url = buildEnterpriseDownloadUrl($releaseName, $info);
$url = buildEnterpriseDownloadUrl($releaseName, $info, $majorVersion);
if ($url !== null) {
return $url;
}
Expand All @@ -77,3 +77,18 @@ function buildDownloadUrl(string $releaseName, array $info): string {
$release['modifier'] === '' ? '' : str_replace(' ', '', strtolower($release['modifier'])),
);
}

function isEol(string $releaseName, array $majorVersion): bool {
if (function_exists('isEnterpriseEol')) {
$isEol = isEnterpriseEol($releaseName, $majorVersion);
if ($isEol !== null) {
return $isEol;
}
}

if (!isset($majorVersion['eol'])) {
return false;
}

return $majorVersion['eol'] < date('Y-m');
}

0 comments on commit 875e78d

Please sign in to comment.