public static GithubRelease CheckForUpdates()
        {
            _thisVersion = DragonVersion.VERSION;
            Console.WriteLine("Checking for new version...");

            GithubRelease newestRelease = null;

            newestRelease = GetNewestReleaseInfo();

            if (newestRelease != null)
            {
                var githubNewestVersion = Convert.ToDecimal(newestRelease.tag_name);

                if (githubNewestVersion > _thisVersion)
                {
                    Console.WriteLine("New version available!\n" + newestRelease.name + " (Current: v" + _thisVersion +
                                      ")\n\nRelease notes:\n" + newestRelease.body + "\n\nDownload: " +
                                      newestRelease.html_url);
                    return(newestRelease);
                }
                Console.WriteLine("Application is up to date!");
            }
            else
            {
                Console.WriteLine("Couldn't download release info.");
            }

            return(null);
        }
        public static async Task UpdateApp(GithubRelease release, IProgress <SimpleTaskProgress> taskProgress)
        {
            Console.WriteLine("Starting update...");
            List <GithubRelease.Asset> assets = release.assets.Where(asset => asset.name.Contains("GUI")).ToList();

            GithubRelease.Asset downloadAsset = GetAssetMatchingRunningVersion(assets);

            string downloadUrl   = downloadAsset.browser_download_url;
            string zipPath       = Directory.GetParent(DragonUtil.CurrentDirectory).FullName + "/" + downloadAsset.name;
            string updaterFolder = Directory.GetParent(DragonUtil.CurrentDirectory).FullName + "/CoreUpdater";

            if (downloadUrl == null)
            {
                return;
            }

            if (File.Exists(zipPath))
            {
                File.Delete(zipPath);
            }

            Console.WriteLine("Downloading " + downloadUrl + "...");
            var progress = new Progress <SimpleTaskProgress>();

            progress.ProgressChanged += (sender, simpleTaskProgress) => taskProgress.Report(simpleTaskProgress);
            await DragonUtil.DownloadFile(downloadUrl, zipPath, "MarkdownToRW_Converter", downloadAsset.size / 1024, progress);

            // extract updater zip to parent folder
            ExtractZipToFolder(DragonUtil.CurrentDirectory + "/CoreUpdater.zip", updaterFolder);

            // run updater, point to this folder & downloaded zip
            if (DragonUtil.CurrentOperatingSystem.IsMacOS() || DragonUtil.CurrentOperatingSystem.IsLinux())
            {
                await DragonUtil.TryToMakeExecutable(updaterFolder + "/CoreUpdater");
            }

            RunCoreUpdater(updaterFolder, zipPath);

            // close app
            Environment.Exit(0);
        }
        private static GithubRelease GetNewestReleaseInfo()
        {
            GithubRelease release = null;

            try
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("User-Agent", "MarkdownToRW_Converter");
                client.DefaultRequestHeaders
                .Accept
                .Add(new MediaTypeWithQualityHeaderValue("application/json"));
                Task <HttpResponseMessage> response = client.GetAsync(RELEASE_URL);

                release = JsonConvert.DeserializeObject <GithubRelease>(response.Result.Content.ReadAsStringAsync()
                                                                        .Result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Update check failed:\n" + e);
            }

            return(release);
        }