/// <summary> /// Initializes a new instance of the <see cref="VirtualParadise"/> class. /// </summary> /// <param name="current">The file information for Virtual Paradise.</param> private VirtualParadise(FileInfo current) { string fileVersion = FileVersionInfo.GetVersionInfo(current.FullName).FileVersion; this.FileInfo = current; try { // Virtual Paradise does not use the Semantic Version standard, // but we can use System.Version as a middle-man, and build a SemVer-complaint // version from its properties. // Edwin pls. https://semver.org/ - you can thank me later. SysVer version = SysVer.Parse(fileVersion); this.Version = GetSemVerFromSystemVersion(version); } catch { try { // pre-release builds *seem* to use Semantic Version strings // and so if System.Version failed to parse, we can just build // a SemVer object immediately this.Version = new SemVer(fileVersion); } catch { // if THAT fails, then I'll need to come back to this... throw new Exception(@"Could not parse version string."); } } }
private static Version SetPackageVersion(Options options, Manifest m) { Version v2; if (options.Version != null) { if (options.Version.StartsWith("+")) { Version v = Version.Parse(m.Metadata.Version); Version vinc = Version.Parse(options.Version.Substring(1)); v2 = new Version(v.Major + vinc.Major, v.Minor + vinc.Minor, v.Build + vinc.Build, 0); } else { v2 = Version.Parse(options.Version); } } else { Assembly asm = FindAssembly(options, m); v2 = asm.GetName().Version; } m.Metadata.Version = v2.ToString(); using (FileStream fileStream = File.Open(options.NuSpec, FileMode.Truncate)) m.Save(fileStream, true); return(v2); }
private bool IsNewUpdate(AutoUpdaterJSON data) { Version newVer = Version.Parse(data.latestVersion); Version currentVer = Version.Parse(Application.version); if (newVer.Build > currentVer.Build && newVer.Minor >= currentVer.Minor && newVer.Major >= currentVer.Major) { return(true); } else if (newVer.Minor > currentVer.Minor && newVer.Major >= currentVer.Major) { return(true); } else if (newVer.Major > currentVer.Major) { return(true); } return(false); }
void Load() { var content = File.ReadAllLines(ConfigurationFile.FullName); foreach (var item in content) { try { if (item.StartsWith("ExtGitVer=")) { ExtGitVer = Version.Parse(item.Substring("ExtGitVer=".Length)); } else if (item.StartsWith("ExtGitCoreVer=")) { ExtGitVerCore = Version.Parse(item.Substring("ExtGitCoreVer=".Length)); } else if (item.StartsWith("MaxFileSize=")) { MaxFileSize = long.Parse(item.Substring("MaxFileSize=".Length)) * 1024; } else if (item.StartsWith("AutoTrack=")) { AutoTrack = bool.Parse(item.Substring("AutoTrack=".Length)); } else if (item.StartsWith("AutoCommitToGit=")) { AutoTrack = bool.Parse(item.Substring("AutoCommitToGit=".Length)); } else if (item.StartsWith("AutoPushAfterCommit=")) { AutoTrack = bool.Parse(item.Substring("AutoPushAfterCommit=".Length)); } else if (item.StartsWith("TraceTriggerLevel=")) { TraceTriggerLevel = double.Parse(item.Substring("TraceTriggerLevel=".Length)); } else if (item.StartsWith("IgnoreIgnoredFile=")) { IgnoreIgnoredFile = bool.Parse(item.Substring("IgnoreIgnoredFile=".Length)); } else if (item.StartsWith("AutoTraceFileType=")) { AutoTraceFileTypes.Add(item.Substring("AutoTraceFileType=".Length)); } else if (item.StartsWith("AutoTraceFilePath=")) { AutoTraceFilePaths.Add(item.Substring("AutoTraceFilePath=".Length)); } else if (item.StartsWith("IgnoredFilePath=")) { IgnoredFilePaths.Add(item.Substring("IgnoredFilePath=".Length)); } } catch (Exception) { } } realDetectionLine = (long)(((double)MaxFileSize) * TraceTriggerLevel); }
/// <summary> /// Initializes a new instance of the <see cref="DockerContainerManager"/> class. /// </summary> /// <param name="settings">The settings.</param> /// <param name="dockerConfiguration"></param> public DockerContainerManager(ContainerResourceSettings settings, DockerConfiguration dockerConfiguration) { _settings = settings; _dockerConfiguration = dockerConfiguration; _client = new DockerClientConfiguration( LocalDockerUri(), null, TimeSpan.FromMinutes(5) ) .CreateClient(Version.Parse("1.25")); _authConfig = GetAuthConfig(); }
public BrowserData(IHttpContextAccessor ctx, IAgriConfigurationRepository sd) { _ctx = ctx; _sd = sd; try { UserAgent.UserAgent ua = new UserAgent.UserAgent(_ctx.HttpContext.Request.Headers["User-Agent"]); BrowserName = ua.Browser.Name; BrowserVersion = ua.Browser.Version; BrowserOs = ua.OS.Name; BrowserAgent = _ctx.HttpContext.Request.Headers["User-Agent"].ToString(); var ab = _sd.GetAllowableBrowsers(); var browser = ab.Where(a => a.Name.Equals(BrowserName, StringComparison.CurrentCultureIgnoreCase)) .SingleOrDefault(); //known.FindIndex(r => r.name == BrowserName); if (BrowserOs == "iOS") { OSValid = false; } else { OSValid = true; if (browser == null) { BrowserValid = false; BrowserName = "Unknown"; } else { BrowserValid = true; var minVer = Version.Parse(browser.MinVersion); var thisVer = Version.Parse(BrowserVersion); if (thisVer < minVer) { BrowserOutofdate = true; } else { BrowserOutofdate = false; } } } } catch (Exception ex) { BrowserName = "Unknown"; throw new Exception("Could not retrieve browser type.!", ex); } }
public static void Check(string name, Version version, string path, int displayTime) { try { new Thread( async() => { try { using (var client = new WebClient()) { var data = await client.DownloadStringTaskAsync( string.Format( "https://raw.githubusercontent.com/{0}/Properties/AssemblyInfo.cs", path)); var gVersion = Version.Parse( new Regex("AssemblyFileVersion\\((\"(.+?)\")\\)").Match(data).Groups[1].Value .Replace("\"", "")); if (gVersion > version) { CustomEvents.Game.OnGameLoad += delegate { Notifications.AddNotification( string.Format( "[{0}] Update available: {1} => {2}!", name, version, gVersion), displayTime); }; } } } catch (Exception ex) { Console.WriteLine(ex); } }).Start(); } catch (Exception ex) { Console.WriteLine(ex); } }
private static void VersionCompleted(object sender, DownloadStringCompletedEventArgs args) { if (args.Cancelled || args.Error != null) { Console.WriteLine("Failed to download internet version."); _ready = true; return; } var match = Regex.Match(args.Result, VersionRegex); var internetVersion = Version.Parse(match.Groups[1].Value); var localVersion = Assembly.GetExecutingAssembly().GetName().Version; if (internetVersion > localVersion) { DownloadNewJson(); } else { _ready = true; } }
/// <summary> /// Load settings by link to configuration file. /// </summary> /// <param name="link">Link to configuration file.</param> /// <returns>true value if loaded from existing file, otherwise loaded as new.</returns> protected virtual bool loadByLink(string link) { InRAM = false; var newCfg = new SolutionEvents(); try { Data = loadJsonConfig(link); warnAboutJsonConfig(SysVersion.Parse(Data.Header.Compatibility)); } catch (FileNotFoundException) { Data = newCfg; InRAM = true; Log.Info("Initialized with new settings."); } catch (Newtonsoft.Json.JsonException ex) { warnAboutXmlConfig(); Log.Error($"Incorrect configuration data: {ex.Message}"); Data = newCfg; //xml -> json 0.8-0.9 InRAM = true; } catch (Exception ex) { Log.Error($"Configuration file `{link}` is corrupted: {ex.Message}"); Log.Debug(ex.StackTrace); Data = newCfg; //TODO: actions in UI, e.g.: restore, new.. InRAM = true; } // Now we'll work with latest version Data.Header.Compatibility = Entity.Version.ToString(); Updated(this, new DataArgs <ISolutionEvents>() { Data = Data }); return(!InRAM); }
//check github API for new release private void CheckUpdates() { Task.Run(() => { try { var release = GitHubRest.GetLatestRelease(); if (release == null) { return; } string version = release.tag_name.Replace("v", ""); var mine = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; var online = Version.Parse(version); if (mine.CompareTo(online) < 0 && release.assets.Any()) { Application.Current.Dispatcher.Invoke((Action) delegate { var dialog = new NewVersion(); dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.Description.Text = release.name + " has been released on " + release.published_at.ToLongDateString() + "\ndo you want to check it out now?"; //dialog.NewFeatures.Text = document.Element("Bcfier").Element("Changelog").Element("NewFeatures").Value; //dialog.BugFixes.Text = document.Element("Bcfier").Element("Changelog").Element("BugFixes").Value; //dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { Process.Start(release.assets.First().browser_download_url); } }); } } catch (System.Exception ex1) { //warning suppressed Console.WriteLine("exception: " + ex1); } }); }
void TryMigrateFromOldVersion(string rpFilename, FileInfo rpDatabaseFile) { FileInfo rOriginalDatabaseFile, rOriginalBattleDetailDatabaseFile; var rBattleDetailFilename = r_UserID + "_Battle.db"; var rBattleDetailDatabaseFile = new FileInfo(Path.Combine(RecordDirectory.FullName, rBattleDetailFilename)); var rDirectories = from rDirectory in RecordDirectory.Parent.EnumerateDirectories() where rDirectory.Name != ProductInfo.AssemblyVersionString && r_VersionRegex.IsMatch(rDirectory.Name) orderby BclVersion.Parse(rDirectory.Name) descending select rDirectory; foreach (var rDirectory in rDirectories) { rOriginalDatabaseFile = new FileInfo(Path.Combine(rDirectory.FullName, rpFilename)); if (!rOriginalDatabaseFile.Exists) { continue; } Move(rOriginalDatabaseFile, rpDatabaseFile); rOriginalBattleDetailDatabaseFile = new FileInfo(Path.Combine(rDirectory.FullName, rBattleDetailFilename)); Move(rOriginalBattleDetailDatabaseFile, rBattleDetailDatabaseFile); if (!rDirectory.EnumerateFileSystemInfos().Any()) { rDirectory.Delete(); } return; } rOriginalDatabaseFile = new FileInfo($@"Records\{r_UserID}.db"); Move(rOriginalDatabaseFile, rpDatabaseFile); rOriginalBattleDetailDatabaseFile = new FileInfo($@"Records\{r_UserID}_Battle.db"); Move(rOriginalBattleDetailDatabaseFile, rBattleDetailDatabaseFile); }
public static bool TrySeparateVersionAndProject(this string value, out Version version, out string project) { try { string actualVersion = value; project = string.Empty; var indexOfVersionSeparator = actualVersion.IndexOf("_", StringComparison.Ordinal); if (indexOfVersionSeparator > 0) { project = actualVersion.Substring(indexOfVersionSeparator); actualVersion = actualVersion.Substring(0, indexOfVersionSeparator); } version = Version.Parse(actualVersion); return(true); } catch { version = null; project = null; return(false); } }
public static void Check(string name, Version version, string path, int displayTime) { try { Task.Factory.StartNew( () => { try { using (var client = new WebClient()) { var data = client.DownloadString( string.Format( "https://raw.githubusercontent.com/{0}/Properties/AssemblyInfo.cs", path)); var gVersion = Version.Parse( new Regex("AssemblyFileVersion\\((\"(.+?)\")\\)").Match(data).Groups[1].Value .Replace("\"", "")); if (gVersion > version) { } } } catch (Exception ex) { Console.WriteLine(ex); } }); } catch (Exception ex) { Console.WriteLine(ex); } }
// This code was a constructor copied from the FrameworkName class, which is located in System.dll. // Parses strings in the following format: "<identifier>, Version=[v|V]<version>, Profile=<profile>" // - The identifier and version is required, profile is optional // - Only three components are allowed. // - The version string must be in the System.Version format; an optional "v" or "V" prefix is allowed private static bool TryParseFrameworkName(string frameworkName, out string identifier, out int version, out string profile) { // For parsing a target Framework moniker, from the FrameworkName class const char c_componentSeparator = ','; const char c_keyValueSeparator = '='; const char c_versionValuePrefix = 'v'; const string c_versionKey = "Version"; const string c_profileKey = "Profile"; identifier = profile = string.Empty; version = 0; if (frameworkName == null || frameworkName.Length == 0) { return(false); } string[] components = frameworkName.Split(c_componentSeparator); version = 0; // Identifer and Version are required, Profile is optional. if (components.Length < 2 || components.Length > 3) { return(false); } // // 1) Parse the "Identifier", which must come first. Trim any whitespace // identifier = components[0].Trim(); if (identifier.Length == 0) { return(false); } bool versionFound = false; profile = null; // // The required "Version" and optional "Profile" component can be in any order // for (int i = 1; i < components.Length; i++) { // Get the key/value pair separated by '=' string[] keyValuePair = components[i].Split(c_keyValueSeparator); if (keyValuePair.Length != 2) { return(false); } // Get the key and value, trimming any whitespace string key = keyValuePair[0].Trim(); string value = keyValuePair[1].Trim(); // // 2) Parse the required "Version" key value // if (key.Equals(c_versionKey, StringComparison.OrdinalIgnoreCase)) { versionFound = true; // Allow the version to include a 'v' or 'V' prefix... Version realVersion = value.Length > 0 && (value[0] == c_versionValuePrefix || value[0] == 'V') ? Version.Parse(value.AsSpan(1)) : Version.Parse(value); // The version class will represent some unset values as -1 internally (instead of 0). version = realVersion.Major * 10000; if (realVersion.Minor > 0) { version += realVersion.Minor * 100; } if (realVersion.Build > 0) { version += realVersion.Build; } } // // 3) Parse the optional "Profile" key value // else if (key.Equals(c_profileKey, StringComparison.OrdinalIgnoreCase)) { if (!string.IsNullOrEmpty(value)) { profile = value; } } else { return(false); } } if (!versionFound) { return(false); } return(true); }
public void PrepareRelease_MasterWithVersionDecrement(string initialVersion, string releaseUnstableTag, string nextVersion) { // create and configure repository this.InitializeSourceControl(); this.Repo.Config.Set("user.name", this.Signer.Name, ConfigurationLevel.Local); this.Repo.Config.Set("user.email", this.Signer.Email, ConfigurationLevel.Local); // create version.json var versionOptions = new VersionOptions() { Version = SemanticVersion.Parse(initialVersion) }; this.WriteVersionFile(versionOptions); // running PrepareRelease should result in an error // because we're trying to add a prerelease tag to a version without prerelease tag this.AssertError( () => new ReleaseManager().PrepareRelease(this.RepoPath, releaseUnstableTag, (nextVersion == null ? null : Version.Parse(nextVersion))), ReleasePreparationError.VersionDecrement); }
public void PrepareRelease_Master( // data for initial setup (version and release options configured in version.json) string initialVersion, string releaseOptionsBranchName, ReleaseVersionIncrement?releaseOptionsVersionIncrement, string releaseOptionsFirstUnstableTag, // arguments passed to PrepareRelease() string releaseUnstableTag, string nextVersion, ReleaseVersionIncrement?parameterVersionIncrement, // expected versions and branch name after running PrepareRelease() string expectedBranchName, string resultingReleaseVersion, string resultingMainVersion) { // create and configure repository this.InitializeSourceControl(); this.Repo.Config.Set("user.name", this.Signer.Name, ConfigurationLevel.Local); this.Repo.Config.Set("user.email", this.Signer.Email, ConfigurationLevel.Local); // create version.json var initialVersionOptions = new VersionOptions() { Version = SemanticVersion.Parse(initialVersion), Release = new ReleaseOptions() { VersionIncrement = releaseOptionsVersionIncrement, BranchName = releaseOptionsBranchName, FirstUnstableTag = releaseOptionsFirstUnstableTag } }; this.WriteVersionFile(initialVersionOptions); var expectedVersionOptionsReleaseBranch = new VersionOptions() { Version = SemanticVersion.Parse(resultingReleaseVersion), Release = new ReleaseOptions() { VersionIncrement = releaseOptionsVersionIncrement, BranchName = releaseOptionsBranchName, FirstUnstableTag = releaseOptionsFirstUnstableTag } }; var expectedVersionOptionsCurrentBrach = new VersionOptions() { Version = SemanticVersion.Parse(resultingMainVersion), Release = new ReleaseOptions() { VersionIncrement = releaseOptionsVersionIncrement, BranchName = releaseOptionsBranchName, FirstUnstableTag = releaseOptionsFirstUnstableTag } }; var initialBranchName = this.Repo.Head.FriendlyName; var tipBeforePrepareRelease = this.Repo.Head.Tip; // prepare release var releaseManager = new ReleaseManager(); releaseManager.PrepareRelease(this.RepoPath, releaseUnstableTag, (nextVersion == null ? null : Version.Parse(nextVersion)), parameterVersionIncrement); // check if a branch was created Assert.Contains(this.Repo.Branches, branch => branch.FriendlyName == expectedBranchName); // PrepareRelease should switch back to the initial branch Assert.Equal(initialBranchName, this.Repo.Head.FriendlyName); // check if release branch contains a new commit // parent of new commit must be the commit before preparing the release var releaseBranch = this.Repo.Branches[expectedBranchName]; { // If the original branch had no -prerelease tag, the release branch has no commit to author. if (string.IsNullOrEmpty(initialVersionOptions.Version.Prerelease)) { Assert.Equal(releaseBranch.Tip.Id, tipBeforePrepareRelease.Id); } else { Assert.NotEqual(releaseBranch.Tip.Id, tipBeforePrepareRelease.Id); Assert.Equal(releaseBranch.Tip.Parents.Single().Id, tipBeforePrepareRelease.Id); } } if (string.IsNullOrEmpty(initialVersionOptions.Version.Prerelease)) { // Verify that one commit was authored. var incrementCommit = this.Repo.Head.Tip; Assert.Single(incrementCommit.Parents); Assert.Equal(tipBeforePrepareRelease.Id, incrementCommit.Parents.Single().Id); } else { // check if current branch contains new commits // - one commit that updates the version (parent must be the commit before preparing the release) // - one commit merging the release branch back to master and resolving the conflict var mergeCommit = this.Repo.Head.Tip; Assert.Equal(2, mergeCommit.Parents.Count()); Assert.Equal(releaseBranch.Tip.Id, mergeCommit.Parents.Skip(1).First().Id); var updateVersionCommit = mergeCommit.Parents.First(); Assert.Single(updateVersionCommit.Parents); Assert.Equal(tipBeforePrepareRelease.Id, updateVersionCommit.Parents.First().Id); } // check version on release branch { var releaseBranchVersion = VersionFile.GetVersion(releaseBranch.Tip); Assert.Equal(expectedVersionOptionsReleaseBranch, releaseBranchVersion); } // check version on master branch { var currentBranchVersion = VersionFile.GetVersion(this.Repo.Head.Tip); Assert.Equal(expectedVersionOptionsCurrentBrach, currentBranchVersion); } }
static async Task Main(string[] args) { var yamlParser = new global::YamlDotNet.Serialization.Deserializer(); DeploymentPayload payload; var data = System.Environment.GetEnvironmentVariable("INPUT_PAYLOAD"); data = Regex.Unescape(data); if (data.StartsWith('"')) { data = data.Remove(0, 1); } if (data.EndsWith('"')) { data = data.Remove(data.Length - 1, 1); } Console.WriteLine(data); payload = Newtonsoft.Json.JsonConvert.DeserializeObject <DeploymentPayload>(data); var branch = payload.Ref; //string path = @"C:\Source\billpay-deployment-qa"; var workingDir = System.Environment.GetEnvironmentVariable("INPUT_WORKINGDIR"); if (string.IsNullOrEmpty(workingDir)) { workingDir = System.IO.Directory.GetCurrentDirectory(); } string path = workingDir; Console.WriteLine("Working Directory: " + path); System.IO.Directory.SetCurrentDirectory(path); path = System.IO.Directory.GetCurrentDirectory(); Console.WriteLine("Working Directory: " + path); var yaml = System.IO.File.ReadAllText(System.IO.Path.Combine(path, @".github/ci/branches.yaml")); var c = new Context(); c.deployment.Payload = payload; c.pr.number = payload.PR; c.build.version = Version.Parse(payload.Version); var result = global::Stubble.Core.StaticStubbleRenderer.Render(yaml, c); var def = yamlParser.Deserialize <BranchesDefinition>(result); var branchDef = def.FindMatch(branch); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(branchDef)); c.deployment.pr = branchDef.PR; c.deployment.app_version = branchDef.AppVersion; c.deployment.dns_zone = branchDef.DnsZone; c.deployment.domain = branchDef.Domain; c.deployment.monolith_version = branchDef.MonolithVersion; c.modules_path = branchDef.modules_path; c.deployment.@namespace = branchDef.Namespace; //load branch config //if auto-deploy is true, then deploy -- otherwise don't string terraform_path = branchDef.deploy_path; //ensure deployPath exists System.IO.Directory.CreateDirectory(terraform_path); string template_path = @".github/deploy/template"; foreach (var file in System.IO.Directory.EnumerateFiles(template_path)) { System.IO.File.Copy(file, System.IO.Path.Combine(terraform_path, System.IO.Path.GetFileName(file)), true); } //update auto.tfvars Render(terraform_path, "app.auto.tfvars", c); Render(terraform_path, "main.tf", c); var version = Version.Parse(c.deployment.Payload.Version); var branchName = "v" + version.Build; // if (branchDef.AutoDeploy) { if (branchDef.RequireApproval) { branchName = "approve/" + "v" + version.Build; } } Console.WriteLine("::set-output name=branch_name::" + branchName); Console.WriteLine("::set-output name=deployment_name::" + branchDef.DeployName); }
public UpdateDetails UpdateInfo() { lock (this) { Version = null; InstallUrl = null; this.LastCheckTime = DateTime.Now; IsFaulted = true; var url = AppConfig.UpdateInfoPath; try { var wr = WebRequest.Create(url); wr.Timeout = 15000; var resp = wr.GetResponse(); var rgrp = resp.GetResponseStream(); if (rgrp != null) { using (var reader = XmlReader.Create(rgrp)) { while (reader.Read()) { if (!reader.IsStartElement()) continue; if (reader.IsEmptyElement) continue; switch (reader.Name.ToLowerInvariant()) { case "version": if (reader.Read()) { Version = Version.Parse(reader.Value); } break; case "installpath": if (reader.Read()) { #if(Release_Test) InstallUrl = "https://s3.amazonaws.com/octgn/releases/test/" + reader.Value.Replace("downloadtest/", ""); #else InstallUrl = "https://s3.amazonaws.com/octgn/releases/live/" + reader.Value.Replace("download/", ""); #endif } break; } } } } if (!String.IsNullOrWhiteSpace(InstallUrl) && Version != null) { IsFaulted = false; } } catch (WebException e) { Log.Warn("", e); IsFaulted = true; } catch (Exception e) { Log.Warn("", e); IsFaulted = true; } return this; } }
public static SVersion GetVersion() { return(SVersion.Parse(Version)); }
public UpdateDetails UpdateInfo() { lock (this) { Version = null; InstallUrl = null; this.LastCheckTime = DateTime.Now; IsFaulted = true; var url = AppConfig.UpdateInfoPath; try { var c = new Octgn.Site.Api.ApiClient(); var info = c.GetReleaseInfo(); if (Program.IsReleaseTest == false) { Version = Version.Parse(info.LiveVersion); this.InstallUrl = info.LiveVersionDownloadLocation; } else { Version = Version.Parse(info.TestVersion); this.InstallUrl = info.TestVersionDownloadLocation; } if (!String.IsNullOrWhiteSpace(InstallUrl) && Version != null) { IsFaulted = false; } } catch (WebException e) { Log.Warn("", e); IsFaulted = true; } catch (Exception e) { Log.Warn("", e); IsFaulted = true; } return this; } }
public void PrepareRelease_MasterWithoutVersionIncrement(string initialVersion, string nextVersion) { // create and configure repository this.InitializeSourceControl(); // create version.json var versionOptions = new VersionOptions() { Version = SemanticVersion.Parse(initialVersion) }; this.WriteVersionFile(versionOptions); // running PrepareRelease should result in an error // because we're trying to set master to the version it already has this.AssertError( () => new ReleaseManager().PrepareRelease(this.RepoPath, null, (nextVersion is null ? null : Version.Parse(nextVersion))), ReleasePreparationError.NoVersionIncrement); }
public void PrepareRelease_MasterWithVersionDecrement(string initialVersion, string releaseUnstableTag, string nextVersion) { // create and configure repository this.InitializeSourceControl(); // create version.json var versionOptions = new VersionOptions() { Version = SemanticVersion.Parse(initialVersion) }; this.WriteVersionFile(versionOptions); // running PrepareRelease should result in an error // because we're setting the version on master to a lower version this.AssertError( () => new ReleaseManager().PrepareRelease(this.RepoPath, releaseUnstableTag, (nextVersion is null ? null : Version.Parse(nextVersion))), ReleasePreparationError.VersionDecrement); }
//Could be serialized to a class that binds to the UI //Could use a json instad than XML private void DownloadUpdateComplete(object sender, DownloadStringCompletedEventArgs e) { try { if (e.Error == null) { var document = XDocument.Parse(e.Result); string version = document.Element("Bcfier").Element("Version").Value; if (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.CompareTo(Version.Parse(version)) < 0) { var dialog = new NewVersion(); dialog.Description.Text = "Version " + version + " is available,\ndo you want to check it out now?"; dialog.NewFeatures.Text = document.Element("Bcfier").Element("Changelog").Element("NewFeatures").Value; dialog.BugFixes.Text = document.Element("Bcfier").Element("Changelog").Element("BugFixes").Value; dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { Process.Start(document.Element("Bcfier").Element("URL").Value); } } } } catch (System.Exception ex1) { //warning suppressed Console.WriteLine("exception: " + ex1); } }
private bool UpdateResolvedTicketsToVersion(ProjectMeta projectMeta) { _logger.Info("Getting all versions which have the fix version of <{0}>", _jiraOptions.FixVersion); string allClosedTicketsWithoutAnAvailableVersion = $"project={projectMeta.key} and status in (Resolved, \"Under Test\", Closed, Done) and fixVersion = {_jiraOptions.FixVersion} order by key"; var client = new JiraClient(Account); bool moreExists = false; const int maxResults = 100; int startAt = 0; var allIssues = new List <Issue>(); do { Issues issues = client.GetIssuesByJql(allClosedTicketsWithoutAnAvailableVersion, startAt, maxResults); allIssues.AddRange(issues.issues.Select(i => i)); if (issues.issues.Count + startAt < issues.total) { moreExists = true; startAt += issues.issues.Count; } else { moreExists = false; } } while (moreExists); if (!allIssues.Any()) { _logger.Info("No tickets found to update"); return(true); } AnotherJiraRestClient.JiraModel.Version addedVersion = AddOrGetExistingVersion(projectMeta); _logger.Info( $"Found <{allIssues.Count}> issues for this release, will be updated to 'Available Version' <{addedVersion.name}>"); var expando = new ExpandoObject(); var asDict = (IDictionary <string, object>)expando; asDict.Add(_jiraOptions.CustomFieldName, addedVersion); var updateIssue = new { fields = expando }; foreach (var issue in allIssues) { _logger.Info($"Processing <{issue.key}>"); var request = new RestRequest { Resource = $"{ResourceUrls.IssueByKey(issue.key)}?fields={_jiraOptions.CustomFieldName}", Method = Method.GET }; // TODO: custom logic to handle some version information specific to Promapp's needs var promappIssue = client.Execute <PromappReleaseIssue>(request, HttpStatusCode.OK); if (promappIssue.fields == null) { throw new InvalidOperationException("Fields is empty, has the Jira API changed?"); } bool updateVersion = false; AnotherJiraRestClient.JiraModel.Version customFieldVersion = promappIssue.fields.customfield_11520; if (customFieldVersion == null) { updateVersion = true; } else { // because versions can have an "_" now string actualVersion = customFieldVersion.name; if (!actualVersion.TrySeparateVersionAndProject(out Version stampedVersion, out string projectName)) { throw new InvalidOperationException($"Couldn't parse custom field value for ticket <{issue.key}> of <{customFieldVersion.name}> to a version"); } // e.g. we have moved from dev->staging if (_jiraOptions.FixVersionObj >= Version.Parse("1.0.0.0") && stampedVersion < Version.Parse("1.0.0.0") && _jiraOptions.AvailableFromVersionObj >= Version.Parse("1.0.0")) { updateVersion = true; } else { _logger.Info($"Issue <{issue.key}> won't get updated as it is already stamped with version <{actualVersion}>"); } } if (updateVersion) { _logger.Info($"Update issue <{issue.key}> with version <{_jiraOptions.AvailableFromVersion}>"); client.UpdateIssueFields(issue.key, updateIssue); } } return(true); }