mirror of
https://github.com/CarmJos/GithubReleases4J.git
synced 2024-09-19 21:55:45 +00:00
[v1.3.0] [A] Add update checker demo.
This commit is contained in:
parent
8445ac812d
commit
2cad1116b9
@ -39,6 +39,7 @@ To provide an easy way to fetch updates and download assets.
|
|||||||
- Size
|
- Size
|
||||||
- ...
|
- ...
|
||||||
- Release's Assets Download
|
- Release's Assets Download
|
||||||
|
- Update check methods. (See demo)
|
||||||
|
|
||||||
## Dependency Usage
|
## Dependency Usage
|
||||||
|
|
||||||
|
@ -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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user