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.
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.
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://mcmap.net/q/143549/-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
© 2022 - 2024 — McMap. All rights reserved.
Version("1.0.0") < Version("1.0.0.0")
for some reason. – Peculate