Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
BoyBACKS committed Mar 30, 2023
1 parent df070de commit f08c5dd
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 19 deletions.
107 changes: 107 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Release Checker - API
Easy to use and lightweight api for notify about new release version from GitHub

## Tabele of Contentes

1. [About](#About)
2. [Short Wiki](#Short-Wiki)
* [Method Summary](#Method-Summary)
* [Errors](#Errors)
* [Working Example](#Working-Example)
3. [Libraries and API's](#Libraries-and-API's)
4. [Installation](#Installation)
5. [Contributing](#contributing)
6. [ToDo](#ToDo)
7. [License](#License)

## About

This api works by getting releases versions via GitHub API, using link
`https://api.github.com/repos/[REPOSITORY AUTHOR]/[REPOSITORY NAME]/releases"`.

The methods described in [Method Summary](#Method-Summary), modify the values of the variables,
```java
private static String version;
private static String repositoryURL;
```
coded in API. This API uses jsonSimple library to work, maven dependency is in [Installation](#Installation).
In case of errors with API please describe it in Issues.


## Short Wiki
### Method Summary

| Type | Method | Description |
|---------|-------------------------------------------------------------|------------------------------------|
| String | getVersion(**String** version) | Get the latest release version |
| String | getRepository(**String** author, **String** repositoryName) | Get the author and repository name |
| boolean | releaseChecker() | Gets state of latest release |


### Errors

| Message | Reason |
|------------------------------------------------------------------------------------------|----------------------------------------------|
| `[ERROR] Assign a version using getVersion(). Setting default value as FALSE.` | You need to specify a version of release |
| `[ERROR] Assign a repository URL using getRepository(). Setting default value as FALSE.` | You need to specify a repository and release |
| `java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0` | There is no releases in that repository |

### Working Example

```java
public static void main(String[] args) {
getVersion("v2.0");
getRepository("boybacks", "xorencrypt");
if (releaseChecker()) {
System.out.println("There is no new versions");
}
else {
System.out.println("There is new version");
}
}
```

## Libraries and API's

* [JSONSimple](https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple)
* [DiscordAPI](https://docs.github.com/)
* [JitPack](https://jitpack.io/)

## Installation
Add this to your maven project in `pom.xml` file:

```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```
```xml
<dependency>
<groupId>com.github.BoyBACKS</groupId>
<artifactId>releasesChecker-API</artifactId>
<version>v1.1</version>
</dependency>
```

```xml
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
```

## Contributing
Pull requests are always welcome. For bigger changes, please open an issue first to discuss what you would like to change.

## ToDo
* For now, we do not expect another versions.

## Donate
Would you like to support my work? [Click here](https://www.buymeacoffee.com/BoyBACKS) how you would like to do it!

## License
[GNU GPLv3](https://choosealicense.com/licenses/gpl-3.0/)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.boybacks</groupId>
<artifactId>releaseschecker</artifactId>
<version>1.0</version>
<version>1.1</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
22 changes: 4 additions & 18 deletions src/main/java/net/boybacks/releaseschecker/ReleaseChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

public class ReleaseChecker {

public static String version;
public static String repositoryURL;
private static String version;
private static String repositoryURL;

public static boolean releaseChecker() {
public static boolean releaseCheck() {
if (version == null) {
System.out.println("[ERROR] Assign a version using getVersion(). Setting default value as FALSE.");
return false;
Expand Down Expand Up @@ -39,18 +39,4 @@ public static String getVersion(String releaseVersion) {
public static String getRepository(String author, String repositoryName) {
return repositoryURL = author + "/" + repositoryName;
}

//Here you can see example release checker!

// public static void main(String[] args) {
// getVersion("v2.0");
// getRepository("boybacks", "xorencrypt");
// if (releaseChecker()) {
// System.out.println("There is no new versions");
// }
// else {
// System.out.println("There is new version");
// }
// }

}
}

0 comments on commit f08c5dd

Please sign in to comment.