private DeployStatus GetStatus() { if (SemanticVersion is null) { return(DeployStatus.Unavailable); } if (AvailablePackageVersions.Count == 0) { return(DeployStatus.NoPackagesAvailable); } SemanticVersion latestAvailable = AvailablePackageVersions.Latest() !; if (SemanticVersion == latestAvailable) { return(DeployStatus.Latest); } if (latestAvailable > SemanticVersion) { LatestNewerAvailable = latestAvailable; return(DeployStatus.UpdateAvailable); } return(DeployStatus.NoLaterAvailable); }
/// <summary> /// 创建引用版本 /// </summary> /// <param name="version">版本</param> public ReferenceVersion(SemanticVersion?version) { Version = version; MinVersion = version; MaxVersion = version; IsIncludeMaxVersion = true; IsIncludeMinVersion = true; }
public ReleaseFile(string sha256, string name, long size, int?stagingPercentage, SemanticVersion?oldVersion = null) { SHA256 = sha256; Name = name; Size = size; StagingPercentage = stagingPercentage; OldVersion = oldVersion; }
/// <summary> /// 创建引用版本 /// </summary> /// <param name="minVersion">最低版本</param> /// <param name="maxVersion">最高版本</param> /// <param name="isIncludeMinVersion">是否包括最低版本</param> /// <param name="isIncludeMaxVersion">是否包括最高版本</param> public ReferenceVersion(SemanticVersion?minVersion, SemanticVersion?maxVersion, bool isIncludeMinVersion, bool isIncludeMaxVersion) { Version = null; MinVersion = minVersion; MaxVersion = maxVersion; IsIncludeMinVersion = isIncludeMinVersion; IsIncludeMaxVersion = isIncludeMaxVersion; }
public bool Equals(SemanticVersion?rhs) { if (ReferenceEquals(rhs, null)) { return(false); } return(this.Major == rhs.Major && this.Minor == rhs.Minor && this.Patch == rhs.Patch); }
public NuGetPackageInstallResult( [NotNull] NuGetPackageId nugetPackageNuGetPackageId, SemanticVersion?semanticVersion, DirectoryInfo?packageDirectory) { NuGetPackageId = nugetPackageNuGetPackageId ?? throw new ArgumentNullException(nameof(nugetPackageNuGetPackageId)); SemanticVersion = semanticVersion; PackageDirectory = packageDirectory; }
public ReleaseEntry( string sha256, string filename, long filesize, bool isDelta, SemanticVersion version, string folderPath, SemanticVersion?oldVersion = null, object?tag = null, int?stagingPercentage = null) { //If it's a delta file then we should also be given an oldVersion if (isDelta) { if (oldVersion == null) { throw new OldVersionRequiredException(); } OldVersion = oldVersion; } if (filesize < 0) { throw new BadFilesizeException(); } //Check hash and file name/path if (!SHA256Util.IsValidSHA256(sha256)) { throw new InvalidHashException(); } if (!filename.IsValidForFileName(out var invalidChar)) { throw new InvalidFileNameException(invalidChar); } if (!folderPath.IsValidForFilePath(out var invalidPathChar)) { throw new InvalidFilePathException(invalidPathChar); } _logger = LoggingCreator.CreateLogger($"{nameof(ReleaseEntry)} ({filename})"); SHA256 = sha256; Filename = filename; Filesize = filesize; IsDelta = isDelta; Version = version; FileLocation = Path.Combine(folderPath, Filename); StagingPercentage = stagingPercentage; Tag = tag; }
/// <inheritdoc /> public bool Equals(SemanticVersion?other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(Version, other.Version) && string.Equals(Suffix, other.Suffix, StringComparison.OrdinalIgnoreCase)); }
public bool Equals(SemanticVersion?obj) { if (ReferenceEquals(obj, null)) { return(false); } return(Major == obj.Major && Minor == obj.Minor && Patch == obj.Patch && PreReleaseTag == obj.PreReleaseTag && BuildMetaData == obj.BuildMetaData); }
/// <inheritdoc /> public int CompareTo(SemanticVersion?other) { if (ReferenceEquals(this, other)) { return(0); } if (other is null) { return(1); } return(Compare(this, other)); }
public int CompareTo(SemanticVersion?value) { if (ReferenceEquals(value, null)) { return(1); } if (Major != value.Major) { if (Major > value.Major) { return(1); } return(-1); } if (Minor != value.Minor) { if (Minor > value.Minor) { return(1); } return(-1); } if (Patch != value.Patch) { if (Patch > value.Patch) { return(1); } return(-1); } if (PreReleaseTag != value.PreReleaseTag) { if (string.Compare(PreReleaseTag, value.PreReleaseTag, StringComparison.InvariantCulture) > 0) { return(1); } return(-1); } return(0); }
/// <summary> /// Creates a new instance of the <see cref="OasDocument"/> class. /// </summary> /// <param name="version">The semantic version number of the OpenAPI Specification version that the OpenAPI document uses. The default is 3.0.0.</param> /// <param name="info">The metadata about the API.</param> /// <param name="servers">The list of <see cref="OasServer"/> instances, which provide connectivity information to a target server.</param> /// <param name="paths">The available paths and operations for the API.</param> /// <param name="components">The list that holds various schemas for the specification.</param> /// <param name="security">The declaration of which security mechanisms can be used across the API.</param> /// <param name="tags">The list of tags used by the specification with additional metadata.</param> /// <param name="externalDocumentation">The external documentation.</param> public OasDocument( SemanticVersion?version = default, OasInformation info = default, IReadOnlyList <OasServer> servers = default, IReadOnlyDictionary <string, OasReferable <OasPath> > paths = default, OasComponents components = default, IReadOnlyList <OasReferable <OasSecurityScheme> > security = default, IReadOnlyList <OasTag> tags = default, OasExternalDocumentation externalDocumentation = default) { Version = version ?? new SemanticVersion(3, 0, 0); Info = info; Servers = servers ?? Array.Empty <OasServer>(); Paths = paths ?? ImmutableDictionary <string, OasReferable <OasPath> > .Empty; Components = components; Security = security ?? Array.Empty <OasReferable <OasSecurityScheme> >(); Tags = tags ?? Array.Empty <OasTag>(); ExternalDocumentation = externalDocumentation; }
private static ReleaseEntry CreateUpdate(string fileLocation, SemanticVersion?version = null, SemanticVersion?oldVersion = null) { //Get details about update file var releaseFileLocation = fileLocation; var fileStream = File.OpenRead(releaseFileLocation); var fileHash = SHA256Util.CreateSHA256Hash(fileStream); var fileLength = fileStream.Length; fileStream.Dispose(); return(new ReleaseEntry( fileHash, Path.GetFileName(releaseFileLocation), fileLength, true, version ?? SemanticVersion.Parse("2021.129.1"), Path.GetDirectoryName(fileLocation), oldVersion ?? SemanticVersion.Parse("2021.129.0"))); }
/// <summary> /// Creates a new instance of the <see cref="Document"/> class. /// </summary> /// <param name="version">The semantic version number of the OpenAPI Specification version that the OpenAPI document uses. The default is 3.0.0.</param> /// <param name="info">The metadata about the API.</param> /// <param name="servers">The list of <see cref="Server"/> instances, which provide connectivity information to a target server.</param> /// <param name="paths">The available paths and operations for the API.</param> /// <param name="components">The list that holds various schemas for the specification.</param> /// <param name="security">The declaration of which security mechanisms can be used across the API.</param> /// <param name="tags">The list of tags used by the specification with additional metadata.</param> /// <param name="externalDocumentation">The external documentation.</param> public Document( SemanticVersion?version = default, Information info = default, IReadOnlyList <Server> servers = default, IReadOnlyDictionary <string, Referable <Path> > paths = default, Components components = default, IReadOnlyList <Referable <SecurityScheme> > security = default, IReadOnlyList <Tag> tags = default, ExternalDocumentation externalDocumentation = default) { Version = version ?? new SemanticVersion(3, 0, 0); Info = info; Servers = servers ?? Array.Empty <Server>(); Paths = paths ?? ReadOnlyDictionary.Empty <string, Referable <Path> >(); Components = components; Security = security ?? Array.Empty <Referable <SecurityScheme> >(); Tags = tags ?? Array.Empty <Tag>(); ExternalDocumentation = externalDocumentation; }
public static ReleaseFile?ReadReleaseFile(string line, out bool successful) { successful = false; var lineS = line.Split(' '); /*Check that the line only has 3/5 lines, if not then * that means it's not a release file for sure*/ if (lineS.Length is < 3 or > 5) { return(null); } var sha256 = lineS[0]; var fileName = lineS[1]; SemanticVersion?oldVersion = null; var stagingPercentage = 0; var hasFilesize = long.TryParse(lineS[2], out var fileSize); var hasOldVersion = lineS.Length > 3 && SemanticVersion.TryParse(lineS[3], out oldVersion); var hasStagingPercentage = lineS.Length > 3 && int.TryParse(lineS[^ 1], out stagingPercentage);
public async Task <InstalledPackage?> InstallPackageAsync( DeploymentExecutionDefinition deploymentExecutionDefinition, DirectoryInfo tempDirectory, bool includeVersion = true, SemanticVersion?explicitVersion = null, CancellationToken cancellationToken = default) { if (deploymentExecutionDefinition is null) { throw new ArgumentNullException(nameof(deploymentExecutionDefinition)); } if (tempDirectory is null) { throw new ArgumentNullException(nameof(tempDirectory)); } string?executePath = deploymentExecutionDefinition.NuGetExePath.WithDefault(_deployerConfiguration.NuGetExePath); if (string.IsNullOrWhiteSpace(executePath)) { throw new InvalidOperationException("The NuGet executable file path is not defined"); } if (!File.Exists(executePath)) { throw new InvalidOperationException($"The NuGet executable file '{executePath}' does not exist"); } var arguments = new List <string> { "install", deploymentExecutionDefinition.PackageId }; void AddVersion(string value) { arguments.Add("-Version"); arguments.Add(value); } if (explicitVersion is {})
public int GetHashCode(SemanticVersion?obj) { if (obj == null) { return(0); } var hash = obj.Major.GetHashCode(); hash = (hash * 397) ^ obj.Minor.GetHashCode(); hash = (hash * 397) ^ obj.Patch.GetHashCode(); if (obj.IsPrerelease) { for (var i = 0; i < obj.PrereleaseLabels.Count; i++) { hash = (hash * 397) ^ StringComparer.Ordinal.GetHashCode(obj.PrereleaseLabels[i]); } } return(hash); }
private static SemanticVersion GetVersion(CommandOptions options, IFileSystem fileSystem, ILogger logger) { SemanticVersion?version = null; if (!string.IsNullOrWhiteSpace(options.PackageVersion)) { if (SemanticVersion.TryParse(options.PackageVersion, out SemanticVersion parsedVersion)) { version = parsedVersion; } else { logger.Error("Invalid semver '{PackageVersion}'", options.PackageVersion); } } else if (!string.IsNullOrWhiteSpace(options.VersionFile)) { var versionFromFile = JsonFileVersionHelper.GetVersionFromJsonFile(options.VersionFile !.ParseAsPath(), fileSystem, logger); if (versionFromFile is { })
public static bool TryParse(string version, string tagPrefixRegex, out SemanticVersion?semanticVersion) { // 这一句为了替换 EasiNote 中包含占位符的版本号。 version = version.Replace(".$", "-").Replace("$", ""); // 以下是原始逻辑。 var match = Regex.Match(version, $"^({tagPrefixRegex})?(?<version>.*)$"); if (!match.Success) { semanticVersion = null; return(false); } version = match.Groups["version"].Value; var parsed = ParseSemVer.Match(version); if (!parsed.Success) { semanticVersion = null; return(false); } var semanticVersionBuildMetaData = parsed.Groups["BuildMetaData"].Value; var fourthPart = parsed.Groups["FourthPart"]; semanticVersion = new SemanticVersion { Major = int.Parse(parsed.Groups["Major"].Value), Minor = parsed.Groups["Minor"].Success ? int.Parse(parsed.Groups["Minor"].Value) : 0, Patch = parsed.Groups["Patch"].Success ? int.Parse(parsed.Groups["Patch"].Value) : 0, PreReleaseTag = parsed.Groups["Tag"].Value, BuildMetaData = semanticVersionBuildMetaData }; return(true); }
public int CompareTo(SemanticVersion?other) { return(SemanticVersionComparer.Instance.Compare(this, other)); }
public static bool TryParse(string versionString, [NotNullWhen(returnValue: true)] out SemanticVersion?version) { // 1.2.3 // v1.2.3 // 1.2.3-alpha // 1.2.3-alpha.1 // 1.2.3-apha.1+build // 1.2.3-apha.1+build.1.2 // 1.2.3+build // 1.2.3+build.1.2 version = default; if (string.IsNullOrEmpty(versionString)) { return(false); } var index = versionString[0] == 'v' || versionString[0] == 'V' ? 1 : 0; if (!TryReadNumber(versionString, ref index, out var major)) { return(false); } if (!TryReadDot(versionString, ref index)) { return(false); } if (!TryReadNumber(versionString, ref index, out var minor)) { return(false); } if (!TryReadDot(versionString, ref index)) { return(false); } if (!TryReadNumber(versionString, ref index, out var patch)) { return(false); } if (!TryReadPrerelease(versionString, ref index, out var prereleaseLabels)) { prereleaseLabels = null; } if (!TryReadMetadata(versionString, ref index, out var metadata)) { metadata = null; } // Should be at the end of the string if (index != versionString.Length) { return(false); } version = new SemanticVersion(major, minor, patch, prereleaseLabels, metadata); return(true); }
public SemanticVersion FindVersion() { this.log.Info($"Running against branch: {context.CurrentBranch} ({context.CurrentCommit?.ToString() ?? "-"})"); if (context.IsCurrentCommitTagged) { this.log.Info($"Current commit is tagged with version {context.CurrentCommitTaggedVersion}, " + "version calculation is for metadata only."); } else { EnsureHeadIsNotDetached(context); } SemanticVersion?taggedSemanticVersion = null; if (context.IsCurrentCommitTagged) { // Will always be 0, don't bother with the +0 on tags var semanticVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(context.CurrentCommit); semanticVersionBuildMetaData.CommitsSinceTag = null; var semanticVersion = new SemanticVersion(context.CurrentCommitTaggedVersion) { BuildMetaData = semanticVersionBuildMetaData }; taggedSemanticVersion = semanticVersion; } var baseVersion = this.baseVersionCalculator.GetBaseVersion(); baseVersion.SemanticVersion.BuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource); SemanticVersion semver; if (context.Configuration?.VersioningMode == VersioningMode.Mainline) { semver = this.mainlineVersionCalculator.FindMainlineModeVersion(baseVersion); } else { if (taggedSemanticVersion?.BuildMetaData == null || (taggedSemanticVersion.BuildMetaData.Sha != baseVersion.SemanticVersion.BuildMetaData.Sha)) { semver = PerformIncrement(baseVersion); semver.BuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource); } else { semver = baseVersion.SemanticVersion; } } var hasPreReleaseTag = semver.PreReleaseTag?.HasTag() == true; var tag = context.Configuration?.Tag; var branchConfigHasPreReleaseTagConfigured = !tag.IsNullOrEmpty(); #pragma warning disable CS8602 // Dereference of a possibly null reference. // context.Configuration.Tag not null when branchConfigHasPreReleaseTagConfigured is true var preReleaseTagDoesNotMatchConfiguration = hasPreReleaseTag && branchConfigHasPreReleaseTagConfigured && semver.PreReleaseTag?.Name != tag; #pragma warning restore CS8602 // Dereference of a possibly null reference. if (semver.PreReleaseTag?.HasTag() != true && branchConfigHasPreReleaseTagConfigured || preReleaseTagDoesNotMatchConfiguration) { UpdatePreReleaseTag(semver, baseVersion.BranchNameOverride); } if (taggedSemanticVersion != null) { // replace calculated version with tagged version only if tagged version greater or equal to calculated version if (semver.CompareTo(taggedSemanticVersion, false) > 0) { taggedSemanticVersion = null; } else if (taggedSemanticVersion.BuildMetaData != null) { // set the commit count on the tagged ver taggedSemanticVersion.BuildMetaData.CommitsSinceVersionSource = semver.BuildMetaData?.CommitsSinceVersionSource; } } return(taggedSemanticVersion ?? semver); }
public bool Equals(SemanticVersion?other) { return(SemanticVersionComparer.Instance.Equals(this, other)); }
public static string?GetApplicationFolder(this SemanticVersion?version) => version == null ? null : "app-" + version;
public async Task ThenNewVersionShouldBeDeployed() { SemanticVersion?semanticVersion = null; var expectedVersion = new SemanticVersion(1, 2, 5); if (WebFixture is null) { throw new DeployerAppException($"{nameof(WebFixture)} is null"); } if (WebFixture.ServerEnvironmentTestSiteConfiguration is null) { throw new DeployerAppException($"{nameof(WebFixture.ServerEnvironmentTestSiteConfiguration)} is null"); } if (WebFixture is null) { throw new DeployerAppException($"{nameof(WebFixture)} is null"); } Output.WriteLine(typeof(StartupModule).FullName); Assert.NotNull(WebFixture?.App?.Host?.Services); using (var httpClient = WebFixture !.App !.Host !.Services.GetRequiredService <IHttpClientFactory>().CreateClient()) { using CancellationTokenSource cancellationTokenSource = WebFixture !.App !.Host !.Services.GetRequiredService <CancellationTokenSource>(); var lifeTime = WebFixture !.App !.Host !.Services.GetRequiredService <IHostApplicationLifetime>(); cancellationTokenSource.Token.Register(() => Debug.WriteLine("Cancellation for app in test")); lifeTime.ApplicationStopped.Register(() => Debug.WriteLine("Stop for app in test")); while (!cancellationTokenSource.Token.IsCancellationRequested && semanticVersion != expectedVersion && !lifeTime.ApplicationStopped.IsCancellationRequested && !WebFixture !.CancellationToken.IsCancellationRequested) { // ReSharper disable MethodSupportsCancellation StartupTaskContext?startupTaskContext = WebFixture !.App !.Host !.Services.GetService <StartupTaskContext>(); if (startupTaskContext is null) { return; } while (!startupTaskContext.IsCompleted && !cancellationTokenSource.Token.IsCancellationRequested) { await Task.Delay(TimeSpan.FromMilliseconds(500)); } var url = new Uri( $"http://localhost:{WebFixture!.ServerEnvironmentTestSiteConfiguration.Port.Port + 1}/applicationmetadata.json"); string contents; try { using HttpResponseMessage responseMessage = await httpClient.GetAsync(url); contents = await responseMessage.Content.ReadAsStringAsync(); Output.WriteLine($"{responseMessage.StatusCode} {contents}"); if (responseMessage.StatusCode == HttpStatusCode.ServiceUnavailable || responseMessage.StatusCode == HttpStatusCode.NotFound) { await Task.Delay(TimeSpan.FromMilliseconds(100)); continue; } Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode); } catch (Exception ex) when(!ex.IsFatal()) { throw new DeployerAppException($"Could not get a valid response from request to '{url}'", ex); } string tempFileName = Path.GetTempFileName(); await File.WriteAllTextAsync(tempFileName, contents, Encoding.UTF8, cancellationTokenSource.Token); var jsonKeyValueConfiguration = new JsonKeyValueConfiguration(tempFileName); if (File.Exists(tempFileName)) { File.Delete(tempFileName); } string actual = jsonKeyValueConfiguration["urn:versioning:semver2:normalized"]; semanticVersion = SemanticVersion.Parse(actual); await Task.Delay(TimeSpan.FromSeconds(1)); // ReSharper restore MethodSupportsCancellation } } if (WebFixture?.Exception is { } exception) { throw new DeployerAppException("Fixture exception", exception); } Assert.Equal(expectedVersion, semanticVersion); }
//TODO: Finish public static async Task <ReleaseEntry> MakeDummyReleaseEntry(bool createFile, string extension, string?filename = null, SemanticVersion?version = null, params InvalidReleaseEntry[] invalidReleaseOptions) { //Create everything that is needed for having a ReleaseEntry filename ??= $"dummy-{Guid.NewGuid()}{extension}"; long filesize; string sha256 = null; var isDelta = false; /*version ??= new Version( * ApplicationMetadata.ApplicationVersion.Major + 1, * ApplicationMetadata.ApplicationVersion.Minor, * ApplicationMetadata.ApplicationVersion.Build >= 0 ? ApplicationMetadata.ApplicationVersion.Build : 0, * ApplicationMetadata.ApplicationVersion.Revision >= 0 ? ApplicationMetadata.ApplicationVersion.Revision : 0); * * var getRandomData = true; * //Create some dummy content so we can make a SHA256 hash to work with * byte[] dummyContent = null; * while (getRandomData) * { * getRandomData = * invalidReleaseOptions.Contains(InvalidReleaseEntry.Data) && dummyContent == null; * dummyContent = new byte[10000]; * _rnd.NextBytes(dummyContent); * sha256 ??= SHA256Util.CreateSHA256Hash(dummyContent, true); * } * filesize = dummyContent.Length; * * var dummyReleaseFileLocation = Path.Combine(ApplicationMetadata.TempFolder, filename); * if (File.Exists(dummyReleaseFileLocation)) * { * File.Delete(dummyReleaseFileLocation); * } * //Put the dummy content onto the disk if we are told to * if (createFile) * { * Directory.CreateDirectory(ApplicationMetadata.TempFolder); * await using var dummyReleaseFile = File.OpenWrite(dummyReleaseFileLocation); * await dummyReleaseFile.WriteAsync(dummyContent, 0, dummyContent.Length); * } * * //Do any data corruption if needed * foreach (var invalidReleaseOption in invalidReleaseOptions) * { * switch (invalidReleaseOption) * { * case InvalidReleaseEntry.SHA256: * sha256 = TestContext.CurrentContext.Random.GetString(64, "abcdefghijkmnopqrstuvwxyz0123456789_@\"/.,\\£$%*&)(~#¬`"); * break; * case InvalidReleaseEntry.Filename: * filename = TestContext.CurrentContext.Random.GetString(20, * "abcdefghijkmnopqrstuvwxyz0123456789_" + Path.GetInvalidFileNameChars()); * break; * case InvalidReleaseEntry.Filesize: * filesize = -1; * break; * case InvalidReleaseEntry.IsDelta: * break; * case InvalidReleaseEntry.Version: * version = new Version(version.Major - 2, version.Minor, version.Build); * break; * default: * * break; * } * }*/ return(new ReleaseEntry(sha256, filename, 0, isDelta, version, string.Empty)); }
public EnvironmentPackageResult(bool isSuccess, SemanticVersion?version) { IsSuccess = isSuccess; Version = version; }
public bool Equals(SemanticVersion?x, SemanticVersion?y) { return(Compare(x, y) == 0); }
private async Task <ExitCode> ExecuteAsync(string file, SemanticVersion?version, CancellationToken cancellationToken = default) { if (string.IsNullOrWhiteSpace(file)) { throw new ArgumentNullException(nameof(file)); } if (!File.Exists(file)) { Logger.Error("The deployment manifest file '{File}' does not exist", file); return(ExitCode.Failure); } string data = DeploymentExecutionDefinitionFileReader.ReadAllData(file); var deploymentExecutionDefinitions = DeploymentExecutionDefinitionParser.Deserialize(data); if (deploymentExecutionDefinitions.Length == 0) { Logger.Error("Could not find any deployment definitions in file '{File}'", file); return(ExitCode.Failure); } if (deploymentExecutionDefinitions.Length == 1) { Logger.Information("Found 1 deployment definition"); } else { Logger.Information("Found {Length} deployment definitions", deploymentExecutionDefinitions.Length); } Logger.Verbose("{Definitions}", string.Join(", ", deploymentExecutionDefinitions.Select(definition => $"{definition}"))); if (deploymentExecutionDefinitions.Length == 1 && deploymentExecutionDefinitions[0].SemanticVersion is null && version is null && _allowInteractive) { Logger.Debug("Found one definition without version and no version has been explicitly set"); Console.WriteLine( "Version is missing in manifest and no version has been set in command line args. Enter a semantic version, eg. 1.2.3"); string?inputVersion = null; if (Environment.UserInteractive && !Debugger.IsAttached && !UnitTestDetector.HasUnitTestInAppDomain) { inputVersion = Console.ReadLine(); } if (string.IsNullOrWhiteSpace(inputVersion)) { throw new InvalidOperationException("Missing version"); } if (SemanticVersion.TryParse(inputVersion, out SemanticVersion semanticInputVersion)) { version = semanticInputVersion; Logger.Debug("Using interactive version from user: {Version}", semanticInputVersion.ToNormalizedString()); } } var exitCode = await _deploymentService .DeployAsync(deploymentExecutionDefinitions, version, cancellationToken).ConfigureAwait(false); if (exitCode.IsSuccess) { Logger.Information( "Successfully deployed deployment execution definition {DeploymentExecutionDefinition}", deploymentExecutionDefinitions); } else { Logger.Error("Failed to deploy definition {DeploymentExecutionDefinition}", deploymentExecutionDefinitions); } return(exitCode); }
public int Compare(SemanticVersion?x, SemanticVersion?y) { if (ReferenceEquals(x, y)) { return(0); } if (x == null) { return(-1); } if (y == null) { return(1); } var result = x.Major.CompareTo(y.Major); if (result != 0) { return(result); } result = x.Minor.CompareTo(y.Minor); if (result != 0) { return(result); } result = x.Patch.CompareTo(y.Patch); if (result != 0) { return(result); } if (!x.IsPrerelease && !y.IsPrerelease) { return(0); } if (x.IsPrerelease && !y.IsPrerelease) { return(-1); } if (!x.IsPrerelease && y.IsPrerelease) { return(1); } for (var i = 0; i < x.PrereleaseLabels.Count && i < y.PrereleaseLabels.Count; i++) { var left = x.PrereleaseLabels[i]; var right = y.PrereleaseLabels[i]; var isLeftNumber = int.TryParse(left, NumberStyles.None, CultureInfo.InvariantCulture, out var leftNumber); var isRightNumber = int.TryParse(right, NumberStyles.None, CultureInfo.InvariantCulture, out var rightNumber); if (isLeftNumber && isRightNumber) { result = leftNumber.CompareTo(rightNumber); if (result != 0) { return(result); } } else { if (isLeftNumber) { return(-1); } if (isRightNumber) { return(1); } result = StringComparer.Ordinal.Compare(left, right); if (result != 0) { return(result); } } } if (x.PrereleaseLabels.Count > y.PrereleaseLabels.Count) { return(1); } if (x.PrereleaseLabels.Count < y.PrereleaseLabels.Count) { return(-1); } return(0); }