|
| 1 | +namespace sigtran.net.Core.Utilities; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Describes one SDK release candidate manifest. |
| 5 | +/// </summary> |
| 6 | +public sealed class SigtranReleaseCandidateManifest |
| 7 | +{ |
| 8 | + /// <summary>Creates a release candidate manifest.</summary> |
| 9 | + /// <param name="packageId">The package id.</param> |
| 10 | + /// <param name="version">The package version.</param> |
| 11 | + /// <param name="commitSha">The source commit SHA.</param> |
| 12 | + /// <param name="readiness">The commercial readiness report.</param> |
| 13 | + public SigtranReleaseCandidateManifest( |
| 14 | + string packageId, |
| 15 | + string version, |
| 16 | + string commitSha, |
| 17 | + SigtranCommercialReadinessReport readiness) |
| 18 | + { |
| 19 | + PackageId = string.IsNullOrWhiteSpace(packageId) ? throw new ArgumentException("Package id is required.", nameof(packageId)) : packageId; |
| 20 | + Version = string.IsNullOrWhiteSpace(version) ? throw new ArgumentException("Version is required.", nameof(version)) : version; |
| 21 | + CommitSha = string.IsNullOrWhiteSpace(commitSha) ? throw new ArgumentException("Commit SHA is required.", nameof(commitSha)) : commitSha; |
| 22 | + Readiness = readiness ?? throw new ArgumentNullException(nameof(readiness)); |
| 23 | + } |
| 24 | + |
| 25 | + /// <summary>The package id.</summary> |
| 26 | + public string PackageId { get; } |
| 27 | + |
| 28 | + /// <summary>The package version.</summary> |
| 29 | + public string Version { get; } |
| 30 | + |
| 31 | + /// <summary>The source commit SHA.</summary> |
| 32 | + public string CommitSha { get; } |
| 33 | + |
| 34 | + /// <summary>The commercial readiness report.</summary> |
| 35 | + public SigtranCommercialReadinessReport Readiness { get; } |
| 36 | + |
| 37 | + /// <summary>Whether this manifest can be used for a public release candidate.</summary> |
| 38 | + public bool CanPublishReleaseCandidate => Readiness.InternalReleaseReady; |
| 39 | + |
| 40 | + /// <summary>Whether this manifest can be promoted to commercial production.</summary> |
| 41 | + public bool CanPromoteToCommercialProduction => Readiness.CommercialReady; |
| 42 | + |
| 43 | + /// <summary>Formats a compact manifest summary.</summary> |
| 44 | + /// <returns>The manifest summary.</returns> |
| 45 | + public string Describe() |
| 46 | + { |
| 47 | + return $"{PackageId} {Version} commit={CommitSha} releaseCandidate={CanPublishReleaseCandidate} commercialProduction={CanPromoteToCommercialProduction}"; |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +/// <summary> |
| 52 | +/// Builds release candidate manifests for the SDK. |
| 53 | +/// </summary> |
| 54 | +public static class SigtranReleaseCandidate |
| 55 | +{ |
| 56 | + /// <summary>Creates a release candidate manifest.</summary> |
| 57 | + /// <param name="version">The package version.</param> |
| 58 | + /// <param name="commitSha">The source commit SHA.</param> |
| 59 | + /// <returns>The release candidate manifest.</returns> |
| 60 | + public static SigtranReleaseCandidateManifest Create(string version, string commitSha) |
| 61 | + { |
| 62 | + return new("Sigtran.Net", version, commitSha, SigtranCommercialReadiness.GetReport()); |
| 63 | + } |
| 64 | +} |
0 commit comments