CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
112 lines
6.1 KiB
C#
112 lines
6.1 KiB
C#
using System.Globalization;
|
|
using Chronos.Core.Packaging;
|
|
|
|
namespace Chronos.Tools.Commands;
|
|
|
|
/// <summary>
|
|
/// <c>pack-installer --setup Chronos.Setup.exe --product Chronos --version 1.2.3 --component Id=folder … --out file</c>:
|
|
/// appends a TPK1 payload (BRIEF §18) to the setup program. Known component ids carry their display name, default
|
|
/// selection, shortcuts and file types; unknown ids are packed as plain, preselected components. The Server
|
|
/// installs only for all users: it is registered as a LocalSystem service, which must run from Program Files.
|
|
/// </summary>
|
|
internal sealed class PackInstallerCommand : ICommand
|
|
{
|
|
private sealed record KnownComponent(string DisplayName, bool DefaultSelected, string Program, bool Desktop, PayloadAssociation? Association, bool AllUsersOnly = false);
|
|
|
|
/// <remarks>The file type's description is the English fallback; setup writes it in its own language (<c>Setup.FileType.*</c>).</remarks>
|
|
private static readonly Dictionary<string, KnownComponent> Known = new(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
["Chronos"] = new("Chronos", true, "Chronos.exe", Desktop: true,
|
|
new PayloadAssociation { Component = "Chronos", Extension = ".chronos", ProgId = "Chronos.Project", Description = "Chronos project", Target = "Chronos.exe" }),
|
|
["Uploader"] = new("Chronos Uploader", true, "Chronos.Uploader.exe", Desktop: true, null),
|
|
["Server"] = new("Chronos Server", false, "Chronos.Server.exe", Desktop: false, null, AllUsersOnly: true),
|
|
};
|
|
|
|
public string Name => "pack-installer";
|
|
public string Summary => "--setup <exe> --product <name> --version <v> --component Id=dir … --out <file>";
|
|
|
|
public Task<int> RunAsync(string[] args)
|
|
{
|
|
var options = Parse(args);
|
|
var setup = Required(options, "setup");
|
|
var output = Required(options, "out");
|
|
if (!File.Exists(setup)) throw new ToolException($"Setup program '{setup}' not found.");
|
|
if (!options.TryGetValue("component", out var specs)) throw new ToolException("At least one --component Id=folder is required.");
|
|
|
|
var components = new List<PayloadComponentSource>();
|
|
var shortcuts = new List<PayloadShortcut>();
|
|
var associations = new List<PayloadAssociation>();
|
|
foreach (var spec in specs)
|
|
{
|
|
var eq = spec.IndexOf('=', StringComparison.Ordinal);
|
|
if (eq <= 0 || eq == spec.Length - 1) throw new ToolException($"--component expects Id=folder, got '{spec}'.");
|
|
var id = spec[..eq];
|
|
var folder = spec[(eq + 1)..];
|
|
if (!PayloadManifest.IdentifierRegex().IsMatch(id)) throw new ToolException($"Component id '{id}' must be letters and digits.");
|
|
if (components.Any(c => c.Id.Equals(id, StringComparison.OrdinalIgnoreCase))) throw new ToolException($"Component '{id}' given twice.");
|
|
if (!Directory.Exists(folder)) throw new ToolException($"Component folder '{folder}' not found.");
|
|
|
|
if (!Known.TryGetValue(id, out var known))
|
|
{
|
|
components.Add(new PayloadComponentSource(id, id, true, folder));
|
|
continue;
|
|
}
|
|
components.Add(new PayloadComponentSource(id, known.DisplayName, known.DefaultSelected, folder, known.AllUsersOnly));
|
|
if (!File.Exists(Path.Combine(folder, known.Program)))
|
|
{
|
|
Console.Error.WriteLine($"warning: {id} has no {known.Program}; no shortcut or file type registered.");
|
|
continue;
|
|
}
|
|
shortcuts.Add(new PayloadShortcut { Component = id, Name = known.DisplayName, Target = known.Program, StartMenu = true, Desktop = known.Desktop });
|
|
if (known.Association is { } association) associations.Add(association);
|
|
}
|
|
|
|
var source = new PayloadSource
|
|
{
|
|
Product = Required(options, "product"),
|
|
Version = Required(options, "version"),
|
|
Components = components,
|
|
Shortcuts = shortcuts,
|
|
Associations = associations,
|
|
};
|
|
try
|
|
{
|
|
Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(output))!);
|
|
var result = PayloadWriter.Write(setup, source, output);
|
|
Console.WriteLine(string.Create(CultureInfo.InvariantCulture,
|
|
$"{output}: {result.FileCount} files in {components.Count} component(s), {Megabytes(result.InstallerBytes)} ({result.InstallerBytes:N0} bytes), installs {Megabytes(result.InstalledBytes)}"));
|
|
return Task.FromResult(0);
|
|
}
|
|
catch (Exception ex) when (ex is PayloadException or ArgumentException or IOException)
|
|
{
|
|
throw new ToolException("pack-installer: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary><c>--key value</c> pairs; every key may repeat (only <c>--component</c> is meant to).</summary>
|
|
private static Dictionary<string, List<string>> Parse(string[] args)
|
|
{
|
|
var allowed = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "setup", "product", "version", "component", "out" };
|
|
var options = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
|
|
for (var i = 0; i < args.Length; i++)
|
|
{
|
|
if (!args[i].StartsWith("--", StringComparison.Ordinal) || !allowed.Contains(args[i][2..]))
|
|
throw new ToolException($"Unexpected argument '{args[i]}'.");
|
|
if (i + 1 >= args.Length) throw new ToolException($"{args[i]} needs a value.");
|
|
var key = args[i][2..];
|
|
if (!options.TryGetValue(key, out var values)) options[key] = values = [];
|
|
values.Add(args[++i]);
|
|
}
|
|
return options;
|
|
}
|
|
|
|
private static string Required(Dictionary<string, List<string>> options, string key)
|
|
{
|
|
if (!options.TryGetValue(key, out var values) || string.IsNullOrWhiteSpace(values[^1])) throw new ToolException($"--{key} is required.");
|
|
if (values.Count > 1) throw new ToolException($"--{key} given more than once.");
|
|
return values[0];
|
|
}
|
|
|
|
private static string Megabytes(long bytes) => (bytes / 1_000_000d).ToString("0.0", CultureInfo.InvariantCulture) + " MB";
|
|
}
|