@@ -63,50 +63,103 @@ graph TD
6363
6464## Update Detection & Notification
6565
66- ### GitHub Release Integration
66+ ### Manual Update Check JSON Contract
6767
68- ** Release API Endpoint** :
68+ ThingConnect Pulse uses a ** static JSON contract** for manual update checks, designed to be offline-safe and simple to implement.
69+
70+ ** Update Check JSON Schema** :
71+ ``` json
72+ {
73+ "$schema" : " http://json-schema.org/draft-07/schema#" ,
74+ "title" : " ThingConnect Pulse Update Check" ,
75+ "type" : " object" ,
76+ "required" : [" current" , " latest" , " notes_url" ],
77+ "properties" : {
78+ "current" : {
79+ "type" : " string" ,
80+ "pattern" : " ^\\ d+\\ .\\ d+\\ .\\ d+(-.+)?$" ,
81+ "description" : " Current application version in SemVer format"
82+ },
83+ "latest" : {
84+ "type" : " string" ,
85+ "pattern" : " ^\\ d+\\ .\\ d+\\ .\\ d+(-.+)?$" ,
86+ "description" : " Latest available version in SemVer format"
87+ },
88+ "notes_url" : {
89+ "type" : " string" ,
90+ "format" : " uri" ,
91+ "description" : " URL to release notes for the latest version"
92+ }
93+ }
94+ }
6995```
70- GET https://api.github.com/repos/MachDatum/ThingConnect.Pulse/releases/latest
96+
97+ ** Example Update Check Response** :
98+ ``` json
99+ {
100+ "current" : " 1.0.0" ,
101+ "latest" : " 1.2.1" ,
102+ "notes_url" : " https://github.com/MachDatum/ThingConnect.Pulse/releases/tag/v1.2.1"
103+ }
71104```
72105
73- ** Response Processing** :
106+ ### Update Check Implementation
107+
108+ ** Manual Update Check Service** :
74109``` csharp
75110public sealed class UpdateService : IUpdateService
76111{
77- public async Task <UpdateInfo > CheckForUpdatesAsync ()
112+ private readonly HttpClient _httpClient ;
113+ private readonly ILogger <UpdateService > _logger ;
114+
115+ public async Task <UpdateInfo > CheckForUpdatesAsync (string updateJsonUrl )
78116 {
79117 try
80118 {
81- using var client = new HttpClient ();
82- client .DefaultRequestHeaders .Add (" User-Agent" , " ThingConnect.Pulse/1.0.0" );
119+ _httpClient .DefaultRequestHeaders .Add (" User-Agent" , " ThingConnect.Pulse/1.0.0" );
83120
84- var response = await client .GetStringAsync (
85- " https://api.github.com/repos/MachDatum/ThingConnect.Pulse/releases/latest" );
86- var release = JsonSerializer .Deserialize <GitHubRelease >(response );
121+ var response = await _httpClient .GetStringAsync (updateJsonUrl );
122+ var updateCheck = JsonSerializer .Deserialize <UpdateCheckResponse >(response );
87123
88- var latestVersion = Version .Parse (release . TagName . TrimStart ( 'v' ) );
89- var currentVersion = Assembly . GetExecutingAssembly (). GetName (). Version ;
124+ var latestVersion = Version .Parse (updateCheck . Latest );
125+ var currentVersion = Version . Parse ( updateCheck . Current ) ;
90126
91127 return new UpdateInfo
92128 {
93129 HasUpdate = latestVersion > currentVersion ,
94130 LatestVersion = latestVersion ,
95131 CurrentVersion = currentVersion ,
96- ReleaseNotes = release .Body ,
97- DownloadUrl = release .Assets .FirstOrDefault ()? .BrowserDownloadUrl ,
98- PublishedAt = release .PublishedAt
132+ NotesUrl = updateCheck .NotesUrl ,
133+ UpdateAvailable = latestVersion > currentVersion
99134 };
100135 }
101136 catch (Exception ex )
102137 {
103- _logger .LogWarning (ex , " Failed to check for updates" );
138+ _logger .LogWarning (ex , " Failed to check for updates from {Url} " , updateJsonUrl );
104139 return UpdateInfo .CheckFailed ();
105140 }
106141 }
107142}
143+
144+ public record UpdateCheckResponse (
145+ string Current ,
146+ string Latest ,
147+ string NotesUrl
148+ );
108149```
109150
151+ ### Static JSON Hosting
152+
153+ ** GitHub Pages Hosting** (Recommended):
154+ - Host ` updates.json ` in the repository's ` gh-pages ` branch
155+ - Accessible via: ` https://machDatum.github.io/ThingConnect.Pulse/updates.json `
156+ - Automatically updated via GitHub Actions on new releases
157+
158+ ** Alternative Hosting Options** :
159+ - ** CDN** : CloudFlare, AWS CloudFront, or Azure CDN for global distribution
160+ - ** Static hosting** : Netlify, Vercel, or similar services
161+ - ** Enterprise** : Internal web servers for air-gapped environments
162+
110163### Update Check Configuration
111164
112165** Settings Options** :
0 commit comments