|
1 |
| -# Updater |
| 1 | +# GitCheck |
| 2 | +GitCheck is a Java library that makes it easy to check for updates to a GitHub repository. |
| 3 | +It utilizes the GitHub API to retrieve information about the latest release and compares it to the current version of your application. |
| 4 | +With GitCheck, you can ensure that your users are always running the latest version of your software. |
2 | 5 |
|
3 |
| -#### Updater is a library for checking for updates for your plugin on GitHub. It uses the GitHub API to get information about the latest release of your plugin and compare it to the current version of your plugin. |
| 6 | +## Features |
| 7 | +- Simple and easy-to-use API |
| 8 | +- Lightweight and efficient |
| 9 | +- Supports Java 9 and above |
| 10 | +- Utilizes the GitHub API for retrieving release information |
| 11 | +- You can add your own implementation for another platform |
4 | 12 |
|
5 |
| -### Usage |
6 |
| -First, you need to create an instance of the `Updater` class by passing the plugin name, current version, and Github repository name as arguments. Then, you can call the `checkUpdates()` method to check for updates and get the `RemoteInformation` object. |
| 13 | +## Installation |
7 | 14 |
|
8 |
| -The `RemoteInformation` object contains information about the update, such as the availability of a new version, the current version, and the download URI. |
| 15 | +To use GitCheck in your project, if you are using Gradle, add the following to your `build.gradle` file: |
9 | 16 |
|
10 |
| -```java |
11 |
| -if (remoteInformation.isAvailableNewVersion()) { |
12 |
| - System.out.println("A new version is available: " + remoteInformation.getCurrentVersion()); |
13 |
| - System.out.println("Download URI: " + remoteInformation.getDownloadUri()); |
14 |
| -} else { |
15 |
| - System.out.println("You are already running the latest version."); |
16 |
| -} |
| 17 | +```kotlin |
| 18 | +maven { url = uri("https://repo.eternalcode.pl/releases") } |
17 | 19 | ```
|
18 | 20 |
|
19 |
| -### Example |
20 |
| -Here's an example of how to can use the Updater in `Spigot` plugin |
21 |
| - |
22 |
| -```java |
23 |
| - |
24 |
| -import com.eternalcode.updater.Updater; |
25 |
| -import com.eternalcode.updater.http.RemoteInformation; |
26 |
| - |
27 |
| -public class MyPlugin { |
| 21 | +```kotlin |
| 22 | +implementation("com.eternalcode:gitcheck:1.0.0") |
| 23 | +``` |
28 | 24 |
|
29 |
| - private Updater updater; |
| 25 | +Or, if you are using Maven, add the following to your `pom.xml` file: |
30 | 26 |
|
31 |
| - public void onEnable() { |
32 |
| - updater = new Updater("MyPlugin", "1.0", "MyGithubUsername/MyPlugin"); |
33 |
| - checkForUpdates(); |
34 |
| - } |
| 27 | +```xml |
| 28 | +<repository> |
| 29 | + <id>eternalcode-releases</id> |
| 30 | + <url>https://repo.eternalcode.pl/releases</url> |
| 31 | +</repository> |
| 32 | +``` |
35 | 33 |
|
36 |
| - private void checkForUpdates() { |
37 |
| - RemoteInformation remoteInformation = updater.checkUpdates(); |
38 |
| - if (remoteInformation.isAvailableNewVersion()) { |
39 |
| - System.out.println("A new version is available: " + remoteInformation.getCurrentVersion()); |
40 |
| - System.out.println("Download URI: " + remoteInformation.getDownloadUri()); |
41 |
| - } else { |
42 |
| - System.out.println("You are already running the latest version."); |
43 |
| - } |
44 |
| - } |
45 |
| -} |
| 34 | +```xml |
| 35 | +<dependency> |
| 36 | + <groupId>com.eternalcode</groupId> |
| 37 | + <artifactId>gitcheck</artifactId> |
| 38 | + <version>1.0.0</version> |
| 39 | +</dependency> |
46 | 40 | ```
|
47 | 41 |
|
48 |
| -### Maven/Gradle |
49 |
| -Get the latest version from [EternalCode Repository](https://repo.eternalcode.pl/#/releases/com/eternalcode/updater) |
| 42 | +## API Usage |
50 | 43 |
|
51 |
| -#### gradle groovy |
52 |
| -```groovy |
53 |
| -maven { url "https://repo.eternalcode.pl/releases" } |
| 44 | +To use GitCheck, you need to create an instance of the `GitCheck` class. |
| 45 | +Create `GitRepository` and `GitTag` objects to specify the repository and the current version of your application. |
| 46 | +Then, call the `checkRelease` method to check for updates. |
54 | 47 |
|
55 |
| -implementation "com.eternalcode:updater:{VERSION}" |
56 |
| -``` |
| 48 | +```java |
| 49 | +public class MyApplication { |
57 | 50 |
|
58 |
| -```kotlin |
59 |
| -maven { url = uri("https://repo.eternalcode.pl/releases") } |
| 51 | + public static void main(String[] args) { |
| 52 | + GitCheck gitCheck = new GitCheck(); |
| 53 | + GitRepository repository = GitRepository.of("Owner", "Project"); |
60 | 54 |
|
61 |
| -implementation("com.eternalcode:updater:{VERSION}") |
62 |
| -``` |
| 55 | + GitCheckResult result = gitCheck.checkRelease(repository, GitTag.of("v1.0.0")); |
63 | 56 |
|
64 |
| -```xml |
65 |
| -<repository> |
66 |
| - <id>eternalcode-reposilite-releases</id> |
67 |
| - <name>EternalCode Repository</name> |
68 |
| - <url>https://repo.eternalcode.pl/releases</url> |
69 |
| -</repository> |
| 57 | + if (!result.isUpToDate()) { |
| 58 | + GitRelease release = result.getLatestRelease(); |
| 59 | + GitTag tag = release.getTag(); |
70 | 60 |
|
71 |
| -<dependency> |
72 |
| -<groupId>com.eternalcode</groupId> |
73 |
| -<artifactId>updater</artifactId> |
74 |
| -<version>{VERSION}</version> |
75 |
| -</dependency> |
76 |
| -``` |
| 61 | + System.out.println("A new version is available: " + tag.getTag()); |
| 62 | + System.out.println("See release page: " + release.getPageUrl()); |
| 63 | + System.out.println("Release date: " + release.getPublishedAt()); |
| 64 | + } |
| 65 | + |
| 66 | + // ... |
| 67 | + } |
77 | 68 |
|
| 69 | +} |
| 70 | +``` |
| 71 | +In this example, `GitCheck` is used to check for updates to the repository `Owner/Project` with the current version `v1.0.0`. |
| 72 | +If a new version is available, the details of the release are printed to the console. |
78 | 73 |
|
| 74 | +## Contributing |
| 75 | +We welcome contributions to GitCheck! |
| 76 | +If you have an idea for a new feature or have found a bug that needs to be fixed, you can [open an issue](https://github.com/EternalCodeTeam/GitCheck/issues/new) or [submit a pull request](https://github.com/EternalCodeTeam/GitCheck/compare) with your changes.<br> |
| 77 | +See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for more information. |
79 | 78 |
|
| 79 | +## License |
| 80 | +GitCheck is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information. |
0 commit comments