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
32 changes: 32 additions & 0 deletions src/GitHub/GetLatestRelease.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\GitHub;

use Tempest\Core\Kernel;
use Tempest\HttpClient\HttpClient;
use Throwable;

final class GetLatestRelease
{
public function __construct(
private HttpClient $httpClient,
) {
}

public function __invoke(): ?string
{
// Default release to the currently running version of Tempest.
$defaultRelease = sprintf('v%s', Kernel::VERSION);

try {
$body = $this->httpClient
->get('https://api.github.com/repos/tempestphp/tempest-framework/releases/latest')
->body;

return json_decode($body)->tag_name ?? $defaultRelease;
} catch (Throwable $e) {
ll($e);
return Kernel::VERSION;
}
}
}
21 changes: 21 additions & 0 deletions src/Web/LatestReleaseViewProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Web;

use App\GitHub\GetLatestRelease;
use Tempest\View\View;
use Tempest\View\ViewProcessor;

final readonly class LatestReleaseViewProcessor implements ViewProcessor
{
public function __construct(
private GetLatestRelease $getLatestRelease,
) {
}

#[\Override]
public function process(View $view): View
{
return $view->data(latest_release: ($this->getLatestRelease)());
}
}
24 changes: 14 additions & 10 deletions src/Web/x-header.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ class="group w-full lg:max-w-5xl xl:max-w-7xl 2xl:max-w-8xl fixed lg:rounded-xl
id="header"
>
<!-- Left side -->
<a href="/" class="flex items-center gap-4">
<!-- Logo -->
<div class="size-8">
<img src="/img/logo-transparent.svg" alt="Tempest logo" class="size-full" />
</div>
<span class="font-medium hidden lg:inline">Tempest</span>
<span class="hidden md:inline text-xs tracking-wide font-medium text-(--ui-text-muted) bg-(--ui-bg)/50 px-2 py-1 rounded-lg border border-(--ui-border)">
v{{ \Tempest\Core\Kernel::VERSION }}
</span>
</a>
<div class="flex items-center gap-4">
<a href="/" class="flex items-center gap-4">
<!-- Logo -->
<div class="size-8">
<img src="/img/logo-transparent.svg" alt="Tempest logo" class="size-full" />
</div>
<span class="font-medium hidden lg:inline">Tempest</span>
</a>

<a class="hidden md:inline text-xs tracking-wide font-medium text-(--ui-text-muted) bg-(--ui-bg)/50 px-2 py-1 rounded-lg border border-(--ui-border)" href="https://github.com/tempestphp/tempest-framework/releases/{{ $latest_release }}">
{{ $latest_release }}
</a>
</div>

<!-- Center -->
<div class="flex items-center gap-4">
<x-search />
Expand Down