diff --git a/README.md b/README.md index 193bc5d..a0b23a0 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ To provide an easy way to fetch updates and download assets. - Size - ... - Release's Assets Download +- Update check methods. (See demo) ## Dependency Usage diff --git a/src/test/java/GithubDemo.java b/src/test/java/GithubDemo.java index d2c209e..5f85091 100644 --- a/src/test/java/GithubDemo.java +++ b/src/test/java/GithubDemo.java @@ -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."); + } + + } + + } + }