diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/Dockerfile b/packages/nextcloud/packages/nextcloud_test_presets/docker/Dockerfile index 3281c481d58..42fc772a6fc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/Dockerfile +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/Dockerfile @@ -1,5 +1,5 @@ ARG SERVER_VERSION -FROM nextcloud:${SERVER_VERSION}-fpm-alpine AS nextcloud +FROM nextcloud:${SERVER_VERSION} AS nextcloud WORKDIR /usr/src/nextcloud diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/cookbook/0.11 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/cookbook/0.11 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/cookbook/0.11 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/cookbook/0.11 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.4 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.4 index 3e30f5a2100..0a5ccd7690c 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.4 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.4 @@ -1,4 +1,4 @@ -SERVER_VERSION=28.0.9 +SERVER_VERSION=28.0.9-fpm-alpine@sha256:03bb2b251184cf288987419f65bbd42a66d708b8ac0cf437e7bc878aef37599e COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.4.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.5 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.5 index fa8219233b2..ad25980d340 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.5 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.5 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.5.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.6 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.6 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.6 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/drop_account/2.6 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/news/25.0 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/news/25.0 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/news/25.0 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/news/25.0 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.10 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.10 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.10 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.10 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.8 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.8 index 5854cd63a4c..b4f673b4ccd 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.8 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.8 @@ -1,4 +1,4 @@ -SERVER_VERSION=28.0.9 +SERVER_VERSION=28.0.9-fpm-alpine@sha256:03bb2b251184cf288987419f65bbd42a66d708b8ac0cf437e7bc878aef37599e COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.9 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.9 index ff1f909ecbe..512f38ffd78 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.9 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/notes/4.9 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/28.0 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/28.0 index baa3504e366..d424b115bc7 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/28.0 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/28.0 @@ -1,4 +1,4 @@ -SERVER_VERSION=28.0.9 +SERVER_VERSION=28.0.9-fpm-alpine@sha256:03bb2b251184cf288987419f65bbd42a66d708b8ac0cf437e7bc878aef37599e COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/29.0 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/29.0 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/29.0 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/server/29.0 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/18.0 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/18.0 index baa3504e366..d424b115bc7 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/18.0 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/18.0 @@ -1,4 +1,4 @@ -SERVER_VERSION=28.0.9 +SERVER_VERSION=28.0.9-fpm-alpine@sha256:03bb2b251184cf288987419f65bbd42a66d708b8ac0cf437e7bc878aef37599e COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/19.0 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/19.0 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/19.0 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/spreed/19.0 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.6 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.6 index 472aa0e79a8..123439ca1ca 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.6 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.6 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.7 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.7 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.7 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.7 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.8 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.8 index 2b371beb28c..17b253e72da 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.8 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/tables/0.8 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.4 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.4 index 0ac2b5509c1..53ee2ec3527 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.4 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.4 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.5 b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.5 index 586228cdaca..8bff62d34bc 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.5 +++ b/packages/nextcloud/packages/nextcloud_test_presets/docker/presets/uppush/1.5 @@ -1,4 +1,4 @@ -SERVER_VERSION=29.0.6 +SERVER_VERSION=29.0.6-fpm-alpine@sha256:c20bea91562e329a61ebdc5105f83295910beddd05285785f05a474ec96a0aa8 COOKBOOK_URL=https://github.com/christianlupus-nextcloud/cookbook-releases/releases/download/v0.11.1/cookbook-0.11.1.tar.gz DROP_ACCOUNT_URL=https://packages.framasoft.org/projects/nextcloud-apps/drop-account/drop_account-2.6.0.tar.gz NEWS_URL=https://github.com/nextcloud/news/releases/download/25.0.0-alpha8/news.tar.gz diff --git a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/generate_presets.dart b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/generate_presets.dart index 23a33c74f2b..f8bb1753b45 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/generate_presets.dart +++ b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/generate_presets.dart @@ -19,8 +19,8 @@ Future generatePresets() async { final httpClient = http.Client(); - final serverVersions = await _getServerVersions(httpClient); - serverVersions.sort((a, b) => b.compareTo(a)); + final serverReleases = await _getServerReleases(httpClient); + serverReleases.sort((a, b) => b.compareTo(a)); final apps = await _getApps(appIDs, httpClient); for (final app in apps) { @@ -31,12 +31,12 @@ Future generatePresets() async { appPresetsDir.createSync(); for (final release in app.releases) { - final serverVersion = release.findLatestServerVersion(serverVersions); - if (serverVersion == null) { + final serverRelease = release.findLatestServerRelease(serverReleases); + if (serverRelease == null) { continue; } - final buffer = StringBuffer()..writeln('SERVER_VERSION=$serverVersion'); + final buffer = StringBuffer()..writeln('SERVER_VERSION=${serverRelease.dockerImageTag}'); for (final a in apps) { buffer @@ -45,15 +45,14 @@ Future generatePresets() async { if (a == app) { buffer.writeln(release.url); } else { - final release = a.findLatestCompatibleRelease(serverVersion) ?? - a.findLatestCompatibleRelease(serverVersion, allowUnstable: true) ?? + final release = a.findLatestCompatibleRelease(serverRelease) ?? + a.findLatestCompatibleRelease(serverRelease, allowUnstable: true) ?? a.findLatestRelease(); buffer.writeln(release.url); } } - File('${appPresetsDir.path}/${release.version.major}.${release.version.minor}') - .writeAsStringSync(buffer.toString()); + File('${appPresetsDir.path}/${release.presetVersion}').writeAsStringSync(buffer.toString()); } } @@ -63,31 +62,31 @@ Future generatePresets() async { } serverPresetsDir.createSync(); - for (final serverVersion in serverVersions) { - final buffer = StringBuffer()..writeln('SERVER_VERSION=$serverVersion'); + for (final serverRelease in serverReleases) { + final buffer = StringBuffer()..writeln('SERVER_VERSION=${serverRelease.dockerImageTag}'); for (final app in apps) { - final release = app.findLatestCompatibleRelease(serverVersion) ?? - app.findLatestCompatibleRelease(serverVersion, allowUnstable: true) ?? + final release = app.findLatestCompatibleRelease(serverRelease) ?? + app.findLatestCompatibleRelease(serverRelease, allowUnstable: true) ?? app.findLatestRelease(); buffer.writeln('${app.id.toUpperCase()}_URL=${release.url}'); } - File('${serverPresetsDir.path}/${serverVersion.major}.${serverVersion.minor}').writeAsStringSync(buffer.toString()); + File('${serverPresetsDir.path}/${serverRelease.presetVersion}').writeAsStringSync(buffer.toString()); } final latestPresetLink = Link('docker/presets/latest'); if (latestPresetLink.existsSync()) { - latestPresetLink.updateSync('server/${serverVersions.first.major}.${serverVersions.first.minor}'); + latestPresetLink.updateSync('server/${serverReleases.first.presetVersion}'); } else { - latestPresetLink.createSync('server/${serverVersions.first.major}.${serverVersions.first.minor}'); + latestPresetLink.createSync('server/${serverReleases.first.presetVersion}'); } httpClient.close(); } -Future> _getServerVersions(http.Client httpClient) async { - final versions = {}; +Future> _getServerReleases(http.Client httpClient) async { + final versions = {}; String? next = 'https://hub.docker.com/v2/repositories/library/nextcloud/tags?page_size=1000'; while (next != null) { @@ -108,17 +107,27 @@ Future> _getServerVersions(http.Client httpClient) async { try { final tag = result as Map; - final version = Version.parse(tag['name'] as String); + final name = tag['name'] as String; + if (!name.endsWith('-fpm-alpine')) { + continue; + } + + final version = Version.parse(name); final normalizedVersion = Version(version.major, version.minor, 0); if (version < core.minVersion) { continue; } + final release = ServerRelease( + version: version, + dockerImageDigest: tag['digest'] as String, + ); + if (!versions.containsKey(normalizedVersion)) { - versions[normalizedVersion] = version; + versions[normalizedVersion] = release; } else if (version > versions[normalizedVersion]) { - versions[normalizedVersion] = version; + versions[normalizedVersion] = release; } } catch (_) {} } diff --git a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app.dart b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app.dart index 6a8777f2aca..fa24cbc1636 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app.dart +++ b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app.dart @@ -12,21 +12,20 @@ class App { final String id; final List releases; - AppRelease? findLatestCompatibleRelease(Version serverVersion, {bool allowUnstable = false}) { + AppRelease? findLatestCompatibleRelease(ServerRelease serverRelease, {bool allowUnstable = false}) { final compatibleReleases = releases .where( (release) => - serverVersion >= release.minimumServerVersion && - serverVersion < release.maximumServerVersion.incrementMajor() && + serverRelease.isCompatible(release.minimumServerVersion, release.maximumServerVersion) && (allowUnstable || !release.version.isPreRelease), ) .toList() - ..sort((a, b) => b.version.compareTo(a.version)); + ..sort((a, b) => b.compareTo(a)); return compatibleReleases.firstOrNull; } AppRelease findLatestRelease() { - final sortedReleases = releases..sort((a, b) => b.version.compareTo(a.version)); + final sortedReleases = releases..sort((a, b) => b.compareTo(a)); return sortedReleases.first; } } diff --git a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app_release.dart b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app_release.dart index 9c742a93ed0..b823677a20b 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app_release.dart +++ b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/app_release.dart @@ -3,7 +3,7 @@ import 'package:nextcloud_test_presets/src/models/models.dart'; /// Describes a release of an [App] from https://apps.nextcloud.com @internal -class AppRelease { +class AppRelease implements Comparable { const AppRelease({ required this.version, required this.url, @@ -16,14 +16,16 @@ class AppRelease { final Version minimumServerVersion; final Version maximumServerVersion; - Version? findLatestServerVersion(List serverVersions) { - final compatibleReleases = serverVersions - .where( - (serverVersion) => - serverVersion >= minimumServerVersion && serverVersion < maximumServerVersion.incrementMajor(), - ) + ServerRelease? findLatestServerRelease(List serverReleases) { + final compatibleReleases = serverReleases + .where((serverRelease) => serverRelease.isCompatible(minimumServerVersion, maximumServerVersion)) .toList() ..sort((a, b) => b.compareTo(a)); return compatibleReleases.firstOrNull; } + + String get presetVersion => '${version.major}.${version.minor}'; + + @override + int compareTo(AppRelease other) => version.compareTo(other.version); } diff --git a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/models.dart b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/models.dart index 7c16245f69a..637303b51d7 100644 --- a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/models.dart +++ b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/models.dart @@ -1,3 +1,5 @@ export 'package:version/version.dart'; + export 'app.dart'; export 'app_release.dart'; +export 'server_release.dart'; diff --git a/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/server_release.dart b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/server_release.dart new file mode 100644 index 00000000000..f8e16b79fb4 --- /dev/null +++ b/packages/nextcloud/packages/nextcloud_test_presets/lib/src/models/server_release.dart @@ -0,0 +1,23 @@ +import 'package:meta/meta.dart'; +import 'package:version/version.dart'; + +@internal +class ServerRelease implements Comparable { + ServerRelease({ + required this.version, + required this.dockerImageDigest, + }); + + final Version version; + + final String dockerImageDigest; + + String get dockerImageTag => '$version@$dockerImageDigest'; + + String get presetVersion => '${version.major}.${version.minor}'; + + bool isCompatible(Version min, Version max) => version >= min && version < max.incrementMajor(); + + @override + int compareTo(ServerRelease other) => version.compareTo(other.version); +}