diff --git a/app/Livewire/Upgrade.php b/app/Livewire/Upgrade.php index f13baa7a7..1b145b244 100644 --- a/app/Livewire/Upgrade.php +++ b/app/Livewire/Upgrade.php @@ -4,6 +4,7 @@ use App\Actions\Server\UpdateCoolify; use App\Models\InstanceSettings; +use App\Services\ChangelogService; use Livewire\Component; class Upgrade extends Component @@ -14,21 +15,57 @@ class Upgrade extends Component public string $latestVersion = ''; + public string $currentVersion = ''; + + public array $changelogEntries = []; + protected $listeners = ['updateAvailable' => 'checkUpdate']; + public function mount() + { + $this->currentVersion = config('constants.coolify.version'); + } + public function checkUpdate() { try { $this->latestVersion = get_latest_version_of_coolify(); + $this->currentVersion = config('constants.coolify.version'); $this->isUpgradeAvailable = data_get(InstanceSettings::get(), 'new_version_available', false); if (isDev()) { $this->isUpgradeAvailable = true; } + $this->loadChangelog(); } catch (\Throwable $e) { return handleError($e, $this); } } + public function loadChangelog() + { + try { + $service = app(ChangelogService::class); + $currentVersion = str_replace('v', '', $this->currentVersion); + + $this->changelogEntries = $service->getEntries(1) + ->filter(function ($entry) use ($currentVersion) { + $entryVersion = str_replace('v', '', $entry->tag_name); + + return version_compare($entryVersion, $currentVersion, '>'); + }) + ->take(3) + ->map(fn ($entry) => [ + 'tag_name' => $entry->tag_name, + 'title' => $entry->title, + 'content_html' => $entry->content_html, + ]) + ->values() + ->toArray(); + } catch (\Throwable $e) { + $this->changelogEntries = []; + } + } + public function upgrade() { try { diff --git a/resources/views/components/upgrade-progress.blade.php b/resources/views/components/upgrade-progress.blade.php new file mode 100644 index 000000000..13eca4f5b --- /dev/null +++ b/resources/views/components/upgrade-progress.blade.php @@ -0,0 +1,143 @@ +@props(['step' => 0]) + +
Are you sure you would like to upgrade your instance to {{ $latestVersion }}?
-Any deployments running during the update process will - fail. Please ensure no deployments are in progress on any server before continuing. -
-You can review the changelogs here.
-If something goes wrong and you cannot upgrade your instance, You can check the following - guide on what to do. -
-+ Reloading in seconds... +
+Any deployments running during the update process will + fail. Please ensure no deployments are in progress on any server before continuing. +
++ If something goes wrong, check the + upgrade guide. +
+