Created
June 16, 2022 09:31
-
-
Save chuongmep/cda0dafc6913b132061a5e75a7390ebe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using Octokit; | |
var client = new GitHubClient(new ProductHeaderValue("xxx")); | |
var releases = client.Repository.Release.GetAll("chuongmep", "revitaddinmanager"); | |
var latest = releases.Result.First(); | |
Console.WriteLine( | |
"The latest release is tagged at {0} and is named {1}", | |
latest.TagName, | |
latest.Name); | |
var webClient = new WebClient(); | |
//webClient.Headers.Add("user-agent", "Anything"); | |
// webClient.Headers.Add("authorization", "token " + GitHubToken); | |
string browserDownloadUrl = latest.Assets[0].BrowserDownloadUrl; | |
string name = latest.Assets[0].Name; | |
Console.WriteLine("What is new:"); | |
Console.WriteLine(latest.Body); | |
webClient.DownloadFileAsync(new Uri(browserDownloadUrl), name); | |
Console.WriteLine("Downloaded {0} to {1}", browserDownloadUrl, name); | |
Console.ReadKey(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment