1
mirror of https://github.com/CarmJos/GithubReleases4J.git synced 2026-06-04 21:18:16 +08:00

[v1.3.0] [A] Add update checker demo.

This commit is contained in:
2022-01-22 15:26:44 +08:00
parent 8445ac812d
commit 2cad1116b9
2 changed files with 27 additions and 0 deletions
+26
View File
@@ -39,4 +39,30 @@ public class GithubDemo {
}
}
public void checkUpdate() {
String owner = "Owner";
String repository = "RepoName";
Integer behindVersions = GithubReleases4J.getVersionBehind(
owner, repository,
"Token",// OAuth token if it is a private repository.
"Current Version Tag"
);
if (behindVersions == null) {
System.out.println("Check failed! Please check updates manually.");
System.out.println("Download at " + GithubReleases4J.getReleasesURL(owner, repository));
} else {
if (behindVersions > 0) {
System.out.println("Outdated! Now behind " + behindVersions + " versions.");
System.out.println("Download latest version at " + GithubReleases4J.getLatestReleaseURL(owner, repository));
} else {
System.out.println("Now is using the latest version.");
}
}
}
}