fix(clients, docs): Lizenz-Antwortformat wiederherstellen, Packager absichern
Regression aus dem vorigen Commit - /api/license/v1/validate lieferte die Antwort im neuen status/error-Umschlag. Der Vertrag dieses Endpunkts ist aber bereits ausgerollt: das Feld "status" auf oberster Ebene trägt den Lizenzzustand (valid, revoked, expired ...). LicenseClient las dadurch "success" statt "valid" — jeder ausgelieferte Client hätte seine Lizenz für ungültig gehalten. Die Lizenz-Endpunkte antworten jetzt wieder ohne Umschlag (Http::raw). Gefunden durch Ausführen der projekteigenen Test-Suite gegen den Server. Packager - FTP-Zugangsdaten standen als Standardwerte im Quelltext und zusätzlich in packager.config.json und in der Integrationsanleitung. Alle drei Fundstellen bereinigt; die Konfigurationsdatei ist nicht mehr versioniert. Zugangsdaten kommen aus Datei, Umgebungsvariablen oder CLI-Argument, sonst bricht das Programm mit einer klaren Meldung ab. - Das Veröffentlichen sendet jetzt ein Token (updateservice:publish) und nutzt den Endpunkt /api/updateservice/v1/publish. - Fehler wurden von einem leeren catch verschluckt, und ohne Erfolgsfall wurde gar nichts ausgegeben. Das Werkzeug meldete am Ende immer Erfolg und lieferte Rückgabewert 0, selbst wenn FTP-Upload und API-Aufruf fehlgeschlagen waren. Jetzt ehrliche Meldungen und Rückgabewerte 0/1/2. - packager.config.json wurde vom csproj nie ins Ausgabeverzeichnis kopiert, weshalb sie dort nie gefunden wurde und stets die hartkodierten Werte griffen. UpdateClient - IsVersionNewer entfernte die Vorabkennung, aber kein führendes "v". Damit scheiterte Version.TryParse bei "v1.4.2" und es wurde auf einen alphabetischen Vergleich zurückgefallen, in dem "v1.9.0" als neuer gilt als "v1.10.0" — derselbe Fehler wie zuvor serverseitig im SQL. Ersetzt durch einen vollständigen semantischen Vergleich, verifiziert mit 16 Testfällen. - Der Rückfall auf die API lag in einem catch-Block, aber GetAsync wirft bei einem 404 keine Exception. Fehlte die statische latest.json, brach die Prüfung ab, statt die API zu befragen. Dokumentation - BUGTRACKER_INTEGRATION_GUIDE.md beschrieb denselben Workflow ein zweites Mal und war bereits auseinandergelaufen: Aufrufe ohne Token, alte Pfade, weder Claim/Lease noch Idempotenz. Ersetzt durch einen Verweis auf das gepflegte Agenten-Handbuch samt Übersicht der Änderungen. - UPDATESERVICE_INTEGRATION_GUIDE.md um Token, Umgebungsvariablen und Rückgabewerte ergänzt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
e7fbc85db4
commit
a74c6fd990
@@ -59,22 +59,39 @@ namespace Deploymentcenter.Client
|
||||
// Path pattern: https://domain/releases/{ProjectId}/{channel}/latest.json
|
||||
string staticUrl = $"{cleanBaseUrl}/releases/{projectId}/{channel}/latest.json";
|
||||
|
||||
HttpResponseMessage response;
|
||||
// Zuerst die statische latest.json, danach die API.
|
||||
//
|
||||
// Der Rueckfall auf die API war zuvor unerreichbar: er lag in
|
||||
// einem catch, aber GetAsync wirft bei einem 404 keine Exception,
|
||||
// sondern liefert eine Antwort mit Statuscode. Fehlte die
|
||||
// latest.json, brach die Pruefung mit "HTTP Error NotFound" ab,
|
||||
// statt die API zu befragen.
|
||||
HttpResponseMessage? response = null;
|
||||
|
||||
try
|
||||
{
|
||||
response = await _httpClient.GetAsync(staticUrl, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Fallback check: Deploymentcenter API endpoint
|
||||
// Path pattern: https://domain/api/updateservice/v1/check?product={projectId}&version={currentVersion}
|
||||
string apiUrl = $"{cleanBaseUrl}/api/updateservice/v1/check?product={Uri.EscapeDataString(projectId)}&version={Uri.EscapeDataString(currentVersion)}";
|
||||
response = null;
|
||||
}
|
||||
|
||||
if (response == null || !response.IsSuccessStatusCode)
|
||||
{
|
||||
response?.Dispose();
|
||||
|
||||
string apiUrl = $"{cleanBaseUrl}/api/updateservice/v1/check"
|
||||
+ $"?product={Uri.EscapeDataString(projectId)}"
|
||||
+ $"&version={Uri.EscapeDataString(currentVersion)}"
|
||||
+ $"&channel={Uri.EscapeDataString(channel)}";
|
||||
|
||||
response = await _httpClient.GetAsync(apiUrl, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
result.Message = $"HTTP Error {response.StatusCode} during update check";
|
||||
result.Message = $"Update-Pruefung fehlgeschlagen: HTTP {(int)response.StatusCode}";
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -214,24 +231,107 @@ namespace Deploymentcenter.Client
|
||||
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prueft, ob <paramref name="remoteVer"/> neuer ist als <paramref name="currentVer"/>.
|
||||
///
|
||||
/// Die vorherige Fassung entfernte zwar die Vorabkennung, nicht aber ein
|
||||
/// fuehrendes "v". Damit scheiterte Version.TryParse bei Angaben wie
|
||||
/// "v1.4.2" und es wurde auf einen alphabetischen Vergleich
|
||||
/// zurueckgefallen - dort gilt "v1.9.0" faelschlich als neuer als
|
||||
/// "v1.10.0". Das entspricht dem Fehler, der serverseitig in der
|
||||
/// SQL-Abfrage steckte.
|
||||
/// </summary>
|
||||
public static bool IsVersionNewer(string currentVer, string remoteVer)
|
||||
{
|
||||
if (string.IsNullOrEmpty(remoteVer)) return false;
|
||||
if (string.IsNullOrEmpty(currentVer)) return true;
|
||||
if (string.IsNullOrWhiteSpace(remoteVer)) return false;
|
||||
if (string.IsNullOrWhiteSpace(currentVer)) return true;
|
||||
|
||||
string CleanVer(string v)
|
||||
return CompareVersions(remoteVer, currentVer) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vergleicht zwei Versionsangaben nach semantischer Ordnung.
|
||||
/// Rueckgabe: negativ wenn a < b, 0 bei Gleichstand, positiv wenn a > b.
|
||||
/// </summary>
|
||||
public static int CompareVersions(string a, string b)
|
||||
{
|
||||
var (coreA, preA) = ParseVersion(a);
|
||||
var (coreB, preB) = ParseVersion(b);
|
||||
|
||||
int length = Math.Max(coreA.Count, coreB.Count);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
int dash = v.IndexOf('-');
|
||||
return dash > 0 ? v.Substring(0, dash) : v;
|
||||
int partA = i < coreA.Count ? coreA[i] : 0;
|
||||
int partB = i < coreB.Count ? coreB[i] : 0;
|
||||
if (partA != partB)
|
||||
{
|
||||
return partA.CompareTo(partB);
|
||||
}
|
||||
}
|
||||
|
||||
if (Version.TryParse(CleanVer(currentVer), out var cVer) &&
|
||||
Version.TryParse(CleanVer(remoteVer), out var rVer))
|
||||
// Eine Version ohne Vorabkennung rangiert ueber derselben mit:
|
||||
// 1.0.0 ist neuer als 1.0.0-rc.1
|
||||
bool emptyA = preA.Count == 0;
|
||||
bool emptyB = preB.Count == 0;
|
||||
if (emptyA && emptyB) return 0;
|
||||
if (emptyA) return 1;
|
||||
if (emptyB) return -1;
|
||||
|
||||
int preLength = Math.Max(preA.Count, preB.Count);
|
||||
for (int i = 0; i < preLength; i++)
|
||||
{
|
||||
return rVer > cVer;
|
||||
if (i >= preA.Count) return -1;
|
||||
if (i >= preB.Count) return 1;
|
||||
|
||||
bool numericA = int.TryParse(preA[i], out int numA);
|
||||
bool numericB = int.TryParse(preB[i], out int numB);
|
||||
|
||||
if (numericA && numericB)
|
||||
{
|
||||
if (numA != numB) return numA.CompareTo(numB);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Rein numerische Bestandteile rangieren unter alphanumerischen.
|
||||
if (numericA != numericB) return numericA ? -1 : 1;
|
||||
|
||||
int cmp = string.CompareOrdinal(preA[i], preB[i]);
|
||||
if (cmp != 0) return cmp > 0 ? 1 : -1;
|
||||
}
|
||||
|
||||
return string.Compare(remoteVer, currentVer, StringComparison.OrdinalIgnoreCase) > 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static (List<int> Core, List<string> Prerelease) ParseVersion(string version)
|
||||
{
|
||||
string value = (version ?? string.Empty).Trim().TrimStart('v', 'V');
|
||||
|
||||
// Build-Metadaten sind fuer die Rangfolge ohne Bedeutung.
|
||||
int plus = value.IndexOf('+');
|
||||
if (plus >= 0) value = value.Substring(0, plus);
|
||||
|
||||
var prerelease = new List<string>();
|
||||
int dash = value.IndexOf('-');
|
||||
if (dash >= 0)
|
||||
{
|
||||
string preString = value.Substring(dash + 1);
|
||||
value = value.Substring(0, dash);
|
||||
if (preString.Length > 0)
|
||||
{
|
||||
prerelease.AddRange(preString.Split('.'));
|
||||
}
|
||||
}
|
||||
|
||||
var core = new List<int>();
|
||||
foreach (string part in value.Split('.'))
|
||||
{
|
||||
string digits = new string(part.Where(char.IsDigit).ToArray());
|
||||
core.Add(digits.Length > 0 ? int.Parse(digits) : 0);
|
||||
}
|
||||
|
||||
if (core.Count == 0) core.Add(0);
|
||||
|
||||
return (core, prerelease);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,19 @@
|
||||
<ProjectReference Include="..\Deploymentcenter.Client\Deploymentcenter.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Die Konfiguration wurde bisher nicht ins Ausgabeverzeichnis kopiert. Da das
|
||||
Programm sie dort sucht, wurde sie nie gefunden - benutzt wurden die
|
||||
hartkodierten Standardwerte im Quelltext. Die Datei ist nicht versioniert;
|
||||
ohne sie greifen Umgebungsvariablen oder CLI-Argumente.
|
||||
-->
|
||||
<ItemGroup>
|
||||
<None Include="packager.config.json" Condition="Exists('packager.config.json')">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packager.config.example.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -15,18 +15,56 @@ using FluentFTP;
|
||||
|
||||
namespace Deploymentcenter.Packager
|
||||
{
|
||||
/// <summary>
|
||||
/// Konfiguration des Packagers.
|
||||
///
|
||||
/// Die Zugangsdaten standen zuvor als Standardwerte direkt im Quelltext und
|
||||
/// lagen damit im Repository. Sie kommen jetzt ausschliesslich aus
|
||||
/// packager.config.json (nicht versioniert) oder aus Umgebungsvariablen.
|
||||
/// Fehlen sie, bricht das Programm mit einer klaren Meldung ab, statt sich
|
||||
/// mit veralteten Werten zu verbinden.
|
||||
/// </summary>
|
||||
public class PackagerConfig
|
||||
{
|
||||
public string FtpHost { get; set; } = "www531.your-server.de";
|
||||
public string FtpHost { get; set; } = "";
|
||||
public int FtpPort { get; set; } = 21;
|
||||
public string FtpUser { get; set; } = "bergisnu_4";
|
||||
public string FtpPass { get; set; } = "o2#M*NN^5EsT";
|
||||
public string FtpUser { get; set; } = "";
|
||||
public string FtpPass { get; set; } = "";
|
||||
public string FtpRemoteBaseDir { get; set; } = "/public_html/releases";
|
||||
public string ApiBaseUrl { get; set; } = "https://dc.mhdf.de";
|
||||
|
||||
/// <summary>
|
||||
/// Token mit dem Recht updateservice:publish. Das Veroeffentlichen eines
|
||||
/// Releases ist nicht mehr unauthentifiziert moeglich.
|
||||
/// </summary>
|
||||
public string ApiToken { get; set; } = "";
|
||||
|
||||
public List<string> ExcludePatterns { get; set; } = new List<string>
|
||||
{
|
||||
"*.pdb", "*.xml", "appsettings.Development.json", "appsettings.Staging.json", "*.log", "logs/*"
|
||||
};
|
||||
|
||||
/// <summary>Umgebungsvariablen haben Vorrang vor der Konfigurationsdatei.</summary>
|
||||
public void ApplyEnvironmentOverrides()
|
||||
{
|
||||
FtpHost = Env("DC_FTP_HOST", FtpHost);
|
||||
FtpUser = Env("DC_FTP_USER", FtpUser);
|
||||
FtpPass = Env("DC_FTP_PASS", FtpPass);
|
||||
ApiBaseUrl = Env("DC_API_URL", ApiBaseUrl);
|
||||
ApiToken = Env("DC_TOKEN", ApiToken);
|
||||
|
||||
string port = Env("DC_FTP_PORT", "");
|
||||
if (int.TryParse(port, out int parsedPort) && parsedPort > 0)
|
||||
{
|
||||
FtpPort = parsedPort;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Env(string name, string fallback)
|
||||
{
|
||||
string? value = Environment.GetEnvironmentVariable(name);
|
||||
return string.IsNullOrWhiteSpace(value) ? fallback : value;
|
||||
}
|
||||
}
|
||||
|
||||
class Program
|
||||
@@ -46,12 +84,43 @@ namespace Deploymentcenter.Packager
|
||||
string configFile = GetArg(args, "--config") ?? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "packager.config.json");
|
||||
|
||||
PackagerConfig config = LoadConfig(configFile);
|
||||
config.ApplyEnvironmentOverrides();
|
||||
|
||||
// Override config with explicit CLI args if provided
|
||||
// Reihenfolge: CLI-Argument, dann Umgebungsvariable, dann Datei.
|
||||
string ftpHost = GetArg(args, "--ftp-host") ?? config.FtpHost;
|
||||
string ftpUser = GetArg(args, "--ftp-user") ?? config.FtpUser;
|
||||
string ftpPass = GetArg(args, "--ftp-pass") ?? config.FtpPass;
|
||||
string remoteBase = GetArg(args, "--remote-dir") ?? config.FtpRemoteBaseDir;
|
||||
string apiToken = GetArg(args, "--token") ?? config.ApiToken;
|
||||
|
||||
var missing = new List<string>();
|
||||
if (string.IsNullOrWhiteSpace(ftpHost)) missing.Add("FTP-Host (--ftp-host / DC_FTP_HOST / ftpHost)");
|
||||
if (string.IsNullOrWhiteSpace(ftpUser)) missing.Add("FTP-Benutzer (--ftp-user / DC_FTP_USER / ftpUser)");
|
||||
if (string.IsNullOrWhiteSpace(ftpPass)) missing.Add("FTP-Passwort (--ftp-pass / DC_FTP_PASS / ftpPass)");
|
||||
|
||||
if (missing.Count > 0)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("[FEHLER] Konfiguration unvollstaendig:");
|
||||
foreach (var item in missing)
|
||||
{
|
||||
Console.WriteLine($" - {item}");
|
||||
}
|
||||
Console.ResetColor();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"Vorlage kopieren: {Path.GetFileName(configFile)}.example -> {Path.GetFileName(configFile)}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(apiToken))
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("[WARNUNG] Kein API-Token gesetzt (--token / DC_TOKEN / apiToken).");
|
||||
Console.WriteLine(" Das Paket wird gebaut und hochgeladen, aber das Deploymentcenter");
|
||||
Console.WriteLine(" erfaehrt nichts davon - Veroeffentlichen erfordert seit Version 2.0");
|
||||
Console.WriteLine(" ein Token mit dem Recht updateservice:publish.");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
publishDir = Path.GetFullPath(publishDir);
|
||||
if (!Directory.Exists(publishDir))
|
||||
@@ -162,6 +231,8 @@ namespace Deploymentcenter.Packager
|
||||
|
||||
Console.WriteLine($"[INFO] Uploading via FTP to {ftpHost}:{config.FtpPort} ({remoteVersionPath})...");
|
||||
|
||||
bool ftpSucceeded = false;
|
||||
|
||||
try
|
||||
{
|
||||
using var ftp = new AsyncFtpClient(ftpHost, ftpUser, ftpPass, config.FtpPort);
|
||||
@@ -241,50 +312,153 @@ namespace Deploymentcenter.Packager
|
||||
Console.WriteLine("[SUCCESS] Updated latest.json on FTP server!");
|
||||
|
||||
await ftp.Disconnect();
|
||||
ftpSucceeded = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine($"[WARNING] FTP upload encountered error: {ex.Message}");
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"[FEHLER] FTP-Upload fehlgeschlagen: {ex.Message}");
|
||||
Console.WriteLine(" Das Paket wurde NICHT ausgeliefert.");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
// 6. Notify Deploymentcenter Web API
|
||||
try
|
||||
{
|
||||
using var http = new HttpClient();
|
||||
string apiPublishUrl = $"{config.ApiBaseUrl.TrimEnd('/')}/api/updateservice/v1/index.php";
|
||||
var payload = new
|
||||
{
|
||||
action = "publish_release",
|
||||
product_slug = project,
|
||||
version = version,
|
||||
channel = channel,
|
||||
release_notes = changelog,
|
||||
download_url = $"{config.ApiBaseUrl.TrimEnd('/')}/releases/{project}/{channel}/{version}/package.tar.gz",
|
||||
sha256_hash = packageSha256,
|
||||
git_commit = gitCommitShort,
|
||||
size_bytes = packageSizeBytes,
|
||||
is_critical = isCritical ? 1 : 0
|
||||
};
|
||||
// 6. Deploymentcenter benachrichtigen
|
||||
//
|
||||
// Zuvor stand hier ein leeres catch, und ohne Erfolgsfall wurde gar
|
||||
// nichts ausgegeben. Ein fehlgeschlagener Aufruf blieb damit
|
||||
// unsichtbar, waehrend das Programm am Ende Erfolg meldete.
|
||||
bool apiNotified = false;
|
||||
string apiMessage = "uebersprungen (kein Token gesetzt)";
|
||||
|
||||
string jsonContent = JsonSerializer.Serialize(payload);
|
||||
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
|
||||
var response = await http.PostAsync(apiPublishUrl, content);
|
||||
if (response.IsSuccessStatusCode)
|
||||
if (!string.IsNullOrWhiteSpace(apiToken))
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("[SUCCESS] Notified Deploymentcenter Web API of new release.");
|
||||
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
|
||||
string apiPublishUrl = $"{config.ApiBaseUrl.TrimEnd('/')}/api/updateservice/v1/publish";
|
||||
|
||||
var payload = new
|
||||
{
|
||||
product_slug = project,
|
||||
version = version,
|
||||
channel = channel,
|
||||
release_notes = changelog,
|
||||
download_url = $"{config.ApiBaseUrl.TrimEnd('/')}/releases/{project}/{channel}/{version}/package.tar.gz",
|
||||
sha256_hash = packageSha256,
|
||||
git_commit = gitCommitShort,
|
||||
size_bytes = packageSizeBytes,
|
||||
is_critical = isCritical
|
||||
};
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, apiPublishUrl)
|
||||
{
|
||||
Content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json")
|
||||
};
|
||||
request.Headers.Add("Authorization", $"Bearer {apiToken}");
|
||||
|
||||
var response = await http.SendAsync(request);
|
||||
string body = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
apiNotified = true;
|
||||
apiMessage = ExtractJsonString(body, "message") ?? "Release im Deploymentcenter eingetragen.";
|
||||
|
||||
string? autoResolved = ExtractJsonString(body, "auto_resolved");
|
||||
if (!string.IsNullOrEmpty(autoResolved) && autoResolved != "0")
|
||||
{
|
||||
apiMessage += $" ({autoResolved} Bugtracker-Item(s) automatisch geschlossen)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
apiMessage = $"HTTP {(int)response.StatusCode}: "
|
||||
+ (ExtractJsonString(body, "message") ?? body.Trim());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
apiMessage = $"Aufruf fehlgeschlagen: {ex.Message}";
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (apiNotified)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine($"[SUCCESS] {apiMessage}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine($"[WARNUNG] Deploymentcenter nicht benachrichtigt - {apiMessage}");
|
||||
}
|
||||
Console.ResetColor();
|
||||
|
||||
// Cleanup temp
|
||||
try { Directory.Delete(outputTempDir, true); } catch { }
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine($"\n[FINISHED] Release v{version} for {project} ({channel}) successfully published!");
|
||||
// Der Rueckgabewert bildet jetzt ab, was tatsaechlich passiert ist.
|
||||
// Zuvor wurde immer 0 und "successfully published" gemeldet, selbst
|
||||
// wenn FTP-Upload und API-Aufruf beide fehlgeschlagen waren.
|
||||
bool fullySucceeded = ftpSucceeded && apiNotified;
|
||||
|
||||
Console.WriteLine();
|
||||
Console.ForegroundColor = fullySucceeded ? ConsoleColor.Green : ConsoleColor.Yellow;
|
||||
Console.WriteLine(fullySucceeded
|
||||
? $"[FERTIG] Release {version} fuer {project} ({channel}) vollstaendig veroeffentlicht."
|
||||
: $"[UNVOLLSTAENDIG] Release {version} fuer {project} ({channel}): "
|
||||
+ $"Upload {(ftpSucceeded ? "ok" : "FEHLGESCHLAGEN")}, "
|
||||
+ $"Registrierung {(apiNotified ? "ok" : "FEHLGESCHLAGEN")}.");
|
||||
Console.ResetColor();
|
||||
return 0;
|
||||
|
||||
return fullySucceeded ? 0 : 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Liest einen einzelnen Wert aus einer JSON-Antwort, ohne ein
|
||||
/// vollstaendiges Modell dafuer zu benoetigen.
|
||||
/// </summary>
|
||||
static string? ExtractJsonString(string json, string propertyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var doc = JsonDocument.Parse(json);
|
||||
return FindProperty(doc.RootElement, propertyName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static string? FindProperty(JsonElement element, string propertyName)
|
||||
{
|
||||
if (element.ValueKind != JsonValueKind.Object)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (element.TryGetProperty(propertyName, out var direct))
|
||||
{
|
||||
return direct.ValueKind == JsonValueKind.String
|
||||
? direct.GetString()
|
||||
: direct.ToString();
|
||||
}
|
||||
|
||||
// Fehlerantworten verpacken die Nachricht in einem "error"-Objekt.
|
||||
foreach (var child in element.EnumerateObject())
|
||||
{
|
||||
if (child.Value.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
string? nested = FindProperty(child.Value, propertyName);
|
||||
if (nested != null)
|
||||
{
|
||||
return nested;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static PackagerConfig LoadConfig(string path)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"_comment": "Kopie als packager.config.json anlegen und ausfuellen. packager.config.json ist per .gitignore ausgeschlossen. Alternativ ueber Umgebungsvariablen: DC_FTP_HOST, DC_FTP_PORT, DC_FTP_USER, DC_FTP_PASS, DC_API_URL, DC_TOKEN.",
|
||||
|
||||
"ftpHost": "ftp.example.com",
|
||||
"ftpPort": 21,
|
||||
"ftpUser": "ftp-user",
|
||||
"ftpPass": "ftp-password",
|
||||
"ftpRemoteBaseDir": "/public_html/releases",
|
||||
|
||||
"apiBaseUrl": "https://dc.example.com",
|
||||
"_apiToken_comment": "Token mit dem Recht updateservice:publish. Im WebUI unter Token-Verwaltung erzeugen.",
|
||||
"apiToken": "",
|
||||
|
||||
"excludePatterns": [
|
||||
"*.pdb",
|
||||
"*.xml",
|
||||
"appsettings.Development.json",
|
||||
"appsettings.Staging.json",
|
||||
"*.log",
|
||||
"logs/**",
|
||||
"scratch/**",
|
||||
"*.tmp"
|
||||
]
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"ftpHost": "www531.your-server.de",
|
||||
"ftpPort": 21,
|
||||
"ftpUser": "bergisnu_4",
|
||||
"ftpPass": "o2#M*NN^5EsT",
|
||||
"ftpRemoteBaseDir": "/public_html/releases",
|
||||
"apiBaseUrl": "https://dc.mhdf.de",
|
||||
"excludePatterns": [
|
||||
"*.pdb",
|
||||
"*.xml",
|
||||
"appsettings.Development.json",
|
||||
"appsettings.Staging.json",
|
||||
"*.log",
|
||||
"logs/**",
|
||||
"scratch/**",
|
||||
"*.tmp"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user