|
1 | 1 | # GithubUpdateCheck |
| 2 | + |
| 3 | +[](https://www.gnu.org/licenses/gpl-3.0) |
| 4 | + |
| 5 | +[](https://www.nuget.org/packages/Mayerch1.GithubUpdateCheck/) |
| 6 | + |
| 7 | +[](https://github.com/mayerch1/GithubUpdateCheck/releases/latest) |
| 8 | + |
2 | 9 | NuGet package to check if an update is available. Always compares to the latest github release |
3 | 10 |
|
| 11 | + |
4 | 12 | ## Usage |
5 | 13 | Create an instance of the `GithubUpdateCheck` and specify your Github username and Github repository, as seen in the url. |
| 14 | + |
| 15 | + |
6 | 16 | ```cs |
| 17 | +using Mayerch1.GithubUpdateCheck; |
| 18 | + |
7 | 19 | GithubUpdateCheck update = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck"); |
8 | 20 | bool isUpdate = update.IsUpdateAvailable("1.0.0", VersionChange.Minor); |
9 | 21 | bool isAsyncUpdate = await update.IsUpdateAvailable("1.0.0.5", VersionChange.Revision); |
10 | 22 | ``` |
11 | 23 |
|
| 24 | +--- |
| 25 | + |
| 26 | +### Incremental Compare |
| 27 | +The default constructor is implicite setting the compare type to `CompareType.Incremental`. |
| 28 | +Alternatively call |
| 29 | +```cs |
| 30 | +GithubUpdateCheck update = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Incremental); |
| 31 | +``` |
| 32 | + |
12 | 33 | The version will be compared to the latest release on Github (e.g. https://github.com/Mayerch1/GithubUpdateCheck/releases/latest). |
13 | 34 | Allowed are the following patterns |
14 | 35 | ``` |
15 | 36 | 1.0.0 |
16 | 37 | 1.0.0.0 |
17 | 38 |
|
18 | | -v.1.0.0.0 |
19 | 39 | v.1.0.0 |
20 | | -
|
21 | | -v1.0.0.0 |
22 | 40 | v1.0.0 |
23 | | -``` |
24 | | -(`v` can be any non-digit) |
25 | | -The version string and the tag of the github release must comply with those patterns, otherwise a `InvalidVersionException` will be thrown. |
26 | 41 |
|
27 | | -The second argument `VersionChange changeLevel` specifies the level of comparison. |
| 42 | +1.0.0.[...].5 (any amount of '.' seperators) |
| 43 | +``` |
| 44 | +`v` can be any non-digit and the version (local and repository) must comply with those patterns, otherwise a `InvalidVersionException` will be thrown |
28 | 45 |
|
| 46 | +The second argument `VersionChange` specifies the level of comparison. |
29 | 47 |
|
30 | 48 | </br>For `Major`, only the first number will be compared (x.0.0.0) |
31 | 49 | </br>For `Minor`, the first and second number will be compared (x.y.0.0) |
32 | 50 | </br>For `Build`, the numbers 1-3 will be compared (x.y.z.0) |
33 | 51 | </br>For `Revision`, all numbers will be compared (x.y.z.a) |
34 | 52 |
|
| 53 | +If the version number if exceeding this enum, simply pass an integer `...IsUpdateAvailable("1.0.0.0.9", (VersionChange)5);`. The index is 1-offset from the Major version and will be corrected if it is too big for the present number. |
35 | 54 |
|
36 | | - |
37 | | -All numbers below the specified level (all 0 is this example) will be ignored. |
38 | | -If the remote or local version has a lower level than the specified compare Method (e.g. `1.2.0` at `Revision`), only |
39 | | -the present version levels will be compared. |
| 55 | +All numbers below the specified level will be ignored. |
40 | 56 |
|
41 | 57 | The prefix `v.` can be present on none, one or both sides. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### Boolean Compare |
| 62 | +If the used version system does not match the "Incremental" Compare, you can use the boolean compare. |
| 63 | +```cs |
| 64 | +GithubUpdateCheck update = new GithubUpdateCheck("Mayerch1", "GithubUpdateCheck", CompareType.Boolean); |
| 65 | +``` |
| 66 | +The class will then compare both version strings (local and remote) and will assume an available update as |
| 67 | +soon as they are not equal. |
0 commit comments