Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check github releases in c#?

Something like this.

void UpdateCheck()
{
    if (GithubApi.GetCurrentRelease().Version > CurrentVersion)
}

How can I do this?

I found some API, https://github.com/octokit/octokit.net

but I can't find this function.

like image 516
Joy Hyuk Lee Avatar asked Sep 05 '14 04:09

Joy Hyuk Lee


People also ask

How do I see my GitHub releases?

Searching for releases in a repository On GitHub.com, navigate to the main page of the repository. To the right of the list of files, click Releases. To search the repository's releases, in the search field at the top of the Releases page, type your query and press Enter.

Are GitHub releases public?

No, currently it's not possible to have public releases in a private repository.

What is release notes in GitHub?

About automatically generated release notes With automatically generated release notes, you can quickly generate an overview of the contents of a release. Automatically generated release notes include a list of merged pull requests, a list of contributors to the release, and a link to a full changelog.

What is Target_commitish?

target_commitish. string. Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists.


2 Answers

Using Octokit.net you should be able to get started using this example from the documentation:

Get All

To retrieve all releases for a repository:

var releases = client.Release.GetAll("octokit", "octokit.net");
var latest = releases[0];
Console.WriteLine(
    "The latest release is tagged at {0} and is named {1}", 
    latest.TagName, 
    latest.Name); 

Alternatively, you could use the API directly:

List releases for a repository

Information about published releases are available to everyone. Only users with push access will receive listings for draft releases.

GET /repos/:owner/:repo/releases
like image 101
Chris Avatar answered Oct 25 '22 03:10

Chris


I updated Chris code with the latest changes to octokit.net as the documentation by Octokit is a bit unclear. The code will not work without the await/async keywords.

using System;
using Octokit;

private async System.Threading.Tasks.Task CheckGitHubNewerVersion()
{
    //Get all releases from GitHub
    //Source: https://octokitnet.readthedocs.io/en/latest/getting-started/
    GitHubClient client = new GitHubClient(new ProductHeaderValue("SomeName"));
    IReadOnlyList<Release> releases = await client.Repository.Release.GetAll("Username", "Repository");
    
    //Setup the versions
    Version latestGitHubVersion = new Version(releases[0].TagName);
    Version localVersion = new Version("X.X.X"); //Replace this with your local version. 
                                                 //Only tested with numeric values.
    
    //Compare the Versions
    //Source: https://stackoverflow.com/questions/7568147/compare-version-numbers-without-using-split-function
    int versionComparison = localVersion.CompareTo(latestGitHubVersion);
    if (versionComparison < 0)
    {
        //The version on GitHub is more up to date than this local release.
    }
    else if (versionComparison > 0)
    {
        //This local version is greater than the release version on GitHub.
    }
    else
    {
        //This local Version and the Version on GitHub are equal.
    }
 }

Here is the NuGet

Install-Package Octokit
like image 24
Rllyyy Avatar answered Oct 25 '22 05:10

Rllyyy