GitHubUpdateChecker

class GitHubUpdateChecker(val repo: String, val currentVersion: String, val latestReleaseTag: String = "latest") : UpdateChecker

With this class you can check if there is an update available using the GitHub releases API. Sample usage:

GitHubUpdateChecker("TheProgramSrc/SimpleCoreAPI", "v0.4.1-SNAPSHOT")
.checkWithPrint() // This will print the message if there is an update available

// You can also check if there is an update available without printing a message
val githubUpdateChecker = GitHubUpdateChecker(logger, "TheProgramSrc/SimpleCoreAPI", "v0.4.1-SNAPSHOT")
if(githubUpdateChecker.checkForUpdates()){
// There is an update available
// Do something here
// For example:
logger.info("Please update! Download it now from here: https://example.com/download")
// Or
logger.info("Please update! Download it now from here: ${githubUpdateChecker.getReleaseData().get("url").asString}")
}

Parameters

repo

The repository to check. The format should be 'Holder/Repository', for example 'TheProgramSrc/SimpleCoreAPI'

currentVersion

the current version (tag name) of the product. (Example: "v0.1.0-SNAPSHOT")

latestReleaseTag

The tag name of the latest release. (Defaults to "latest")

Constructors

Link copied to clipboard
constructor(repo: String, currentVersion: String, latestReleaseTag: String = "latest")

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun checkForUpdates(): Boolean

Checks if there is an update available

Link copied to clipboard
open override fun checkWithPrint()

Checks if there is an update available and prints a message if there is one asking the end user to update the product.

Link copied to clipboard
open override fun getReleaseData(id: String): JsonObject

Gets the information of a single release Object Sample: { "published_at": "2022-07-15T21:51:46.397962Z", "version": "v0.4.1-SNAPSHOT", "url": "https://github.com/TheProgramSrc/SimpleCoreAPI/releases/tag/v0.4.1-SNAPSHOT", "author_url": "https://github.com/Im-Fran" }