File tree Expand file tree Collapse file tree 3 files changed +67
-10
lines changed Expand file tree Collapse file tree 3 files changed +67
-10
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \GitHub ;
4
+
5
+ use Tempest \Core \Kernel ;
6
+ use Tempest \HttpClient \HttpClient ;
7
+ use Throwable ;
8
+
9
+ final class GetLatestRelease
10
+ {
11
+ public function __construct (
12
+ private HttpClient $ httpClient ,
13
+ ) {
14
+ }
15
+
16
+ public function __invoke (): ?string
17
+ {
18
+ // Default release to the currently running version of Tempest.
19
+ $ defaultRelease = sprintf ('v%s ' , Kernel::VERSION );
20
+
21
+ try {
22
+ $ body = $ this ->httpClient
23
+ ->get ('https://api.github.com/repos/tempestphp/tempest-framework/releases/latest ' )
24
+ ->body ;
25
+
26
+ return json_decode ($ body )->tag_name ?? $ defaultRelease ;
27
+ } catch (Throwable $ e ) {
28
+ ll ($ e );
29
+ return Kernel::VERSION ;
30
+ }
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Web ;
4
+
5
+ use App \GitHub \GetLatestRelease ;
6
+ use Tempest \View \View ;
7
+ use Tempest \View \ViewProcessor ;
8
+
9
+ final readonly class LatestReleaseViewProcessor implements ViewProcessor
10
+ {
11
+ public function __construct (
12
+ private GetLatestRelease $ getLatestRelease ,
13
+ ) {
14
+ }
15
+
16
+ #[\Override]
17
+ public function process (View $ view ): View
18
+ {
19
+ return $ view ->data (latest_release: ($ this ->getLatestRelease )());
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -15,16 +15,20 @@ class="group w-full lg:max-w-5xl xl:max-w-7xl 2xl:max-w-8xl fixed lg:rounded-xl
15
15
id="header"
16
16
>
17
17
<!-- Left side -->
18
- <a href="/" class="flex items-center gap-4">
19
- <!-- Logo -->
20
- <div class="size-8">
21
- <img src="/img/logo-transparent.svg" alt="Tempest logo" class="size-full" />
22
- </div>
23
- <span class="font-medium hidden lg:inline">Tempest</span>
24
- <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)">
25
- v{{ \Tempest\Core\Kernel::VERSION }}
26
- </span>
27
- </a>
18
+ <div class="flex items-center gap-4">
19
+ <a href="/" class="flex items-center gap-4">
20
+ <!-- Logo -->
21
+ <div class="size-8">
22
+ <img src="/img/logo-transparent.svg" alt="Tempest logo" class="size-full" />
23
+ </div>
24
+ <span class="font-medium hidden lg:inline">Tempest</span>
25
+ </a>
26
+
27
+ <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 }}">
28
+ {{ $latest_release }}
29
+ </a>
30
+ </div>
31
+
28
32
<!-- Center -->
29
33
<div class="flex items-center gap-4">
30
34
<x-search />
You can’t perform that action at this time.
0 commit comments