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.
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.
No, currently it's not possible to have public releases in a private repository.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With