Skip to content
Commits on Source (12)
......@@ -25,6 +25,10 @@ jobs:
run: echo ${{steps.tag.outputs.tag}}
# GENERATE CHANGELOG, RELEASE
- id: conventional_changelog
uses: ardalanamini/auto-changelog@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@latest
......@@ -36,7 +40,7 @@ jobs:
body: |
Automatic pre-release of version: **${{steps.tag.outputs.tag}}**
**Changes in this pre-release:**
TO BE COPY'N'PASTED BY GRIEFED FROM GITLAB
${{ steps.conventional_changelog.outputs.changelog }}
draft: false
prerelease: true
......@@ -53,7 +57,7 @@ jobs:
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew build -Pversion=${CI_COMMIT_TAG} --info --no-daemon -x test
./gradlew build -Pversion=${{steps.tag.outputs.tag}} --info --no-daemon -x test
- name: List files
run: ls -ahl build/libs
......@@ -78,8 +82,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/ServerPackCreator-${{steps.tag.outputs.tag}}.jar
asset_name: ServerPackCreator-${{steps.tag.outputs.tag}}.jar
asset_path: ./build/libs/VersionChecker-${{steps.tag.outputs.tag}}.jar
asset_name: VersionChecker-${{steps.tag.outputs.tag}}.jar
asset_content_type: application/jar
- name: Upload Release Asset Sources Jar
......@@ -89,8 +93,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/ServerPackCreator-${{steps.tag.outputs.tag}}-sources.jar
asset_name: ServerPackCreator-${{steps.tag.outputs.tag}}-sources.jar
asset_path: ./build/libs/VersionChecker-${{steps.tag.outputs.tag}}-sources.jar
asset_name: VersionChecker-${{steps.tag.outputs.tag}}-sources.jar
asset_content_type: application/jar
- name: Upload Release Asset Javadoc Jar
......@@ -100,8 +104,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/ServerPackCreator-${{steps.tag.outputs.tag}}-javadoc.jar
asset_name: ServerPackCreator-${{steps.tag.outputs.tag}}-javadoc.jar
asset_path: ./build/libs/VersionChecker-${{steps.tag.outputs.tag}}-javadoc.jar
asset_name: VersionChecker-${{steps.tag.outputs.tag}}-javadoc.jar
asset_content_type: application/jar
- name: Get current date
......@@ -127,4 +131,4 @@ jobs:
--field "Author;[Griefed]($GITHUB_SERVER_URL/Griefed)" \
--field "Platform;[GitHub]($GITHUB_SERVER_URL)" \
--footer "Released at ${{ steps.date.outputs.today }}" \
--footer-icon "https://i.griefed.de/images/2022/01/21/start_generation.png"
\ No newline at end of file
--footer-icon "https://i.griefed.de/images/2022/01/21/start_generation.png"
......@@ -23,6 +23,10 @@ jobs:
run: echo ${{steps.tag.outputs.tag}}
# GENERATE CHANGELOG, RELEASE
- id: conventional_changelog
uses: ardalanamini/auto-changelog@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@latest
......@@ -32,9 +36,9 @@ jobs:
tag_name: ${{ github.ref }}
release_name: Release ${{steps.tag.outputs.tag}}
body: |
Automatic pre-release of version: **${{steps.tag.outputs.tag}}**
**Changes in this pre-release:**
TO BE COPY'N'PASTED BY GRIEFED FROM GITLAB
Automatic release of version: **${{steps.tag.outputs.tag}}**
**Changes in this release:**
${{ steps.conventional_changelog.outputs.changelog }}
draft: false
prerelease: false
......@@ -51,7 +55,7 @@ jobs:
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew build -Pversion=${CI_COMMIT_TAG} --info --no-daemon -x test
./gradlew build -Pversion=${{steps.tag.outputs.tag}} --info --no-daemon -x test
- name: List files
run: ls -ahl build/libs
......@@ -76,8 +80,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/ServerPackCreator-${{steps.tag.outputs.tag}}.jar
asset_name: ServerPackCreator-${{steps.tag.outputs.tag}}.jar
asset_path: ./build/libs/VersionChecker-${{steps.tag.outputs.tag}}
asset_name: VersionChecker-${{steps.tag.outputs.tag}}.jar
asset_content_type: application/jar
- name: Upload Release Asset Sources Jar
......@@ -87,8 +91,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/ServerPackCreator-${{steps.tag.outputs.tag}}-sources.jar
asset_name: ServerPackCreator-${{steps.tag.outputs.tag}}-sources.jar
asset_path: ./build/libs/VersionChecker-${{steps.tag.outputs.tag}}-sources.jar
asset_name: VersionChecker-${{steps.tag.outputs.tag}}-sources.jar
asset_content_type: application/jar
- name: Upload Release Asset Javadoc Jar
......@@ -98,8 +102,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/ServerPackCreator-${{steps.tag.outputs.tag}}-javadoc.jar
asset_name: ServerPackCreator-${{steps.tag.outputs.tag}}-javadoc.jar
asset_path: ./build/libs/VersionChecker-${{steps.tag.outputs.tag}}-javadoc.jar
asset_name: VersionChecker-${{steps.tag.outputs.tag}}-javadoc.jar
asset_content_type: application/jar
- name: Get current date
......@@ -125,4 +129,4 @@ jobs:
--field "Author;[Griefed]($GITHUB_SERVER_URL/Griefed)" \
--field "Platform;[GitHub]($GITHUB_SERVER_URL)" \
--footer "Released at ${{ steps.date.outputs.today }}" \
--footer-icon "https://i.griefed.de/images/2022/01/21/start_generation.png"
\ No newline at end of file
--footer-icon "https://i.griefed.de/images/2022/01/21/start_generation.png"
......@@ -29,7 +29,6 @@ jobs:
path: |
build/libs/
!build/libs/libraries/
frontend/dist/spa
if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn`
- uses: actions/upload-artifact@v2
if: failure()
......
......@@ -105,7 +105,7 @@ Generate Release:
artifacts: false
- job: secret_detection
artifacts: false
image: ghcr.io/griefed/gitlab-ci-cd:2.0.0
image: ghcr.io/griefed/gitlab-ci-cd:2.0.3
script:
- npx semantic-release
rules:
......@@ -155,7 +155,7 @@ Build Release:
Publish Maven Artifacts:
stage: Build Release
image: ghcr.io/griefed/baseimage-ubuntu-jdk-8:2.0.2
image: ghcr.io/griefed/baseimage-ubuntu-jdk-8:2.0.6
before_script:
- echo "**** Running in $CI_JOB_ID ****"
- echo "**** Java location ****"
......@@ -175,7 +175,7 @@ Publish Maven Artifacts:
Inform About Release:
stage: Build Release
image: ghcr.io/griefed/gitlab-ci-cd:2.0.0
image: ghcr.io/griefed/gitlab-ci-cd:2.0.3
needs:
- job: Build Release
artifacts: false
......
### [1.0.7](https://git.griefed.de/Griefed/VersionChecker/compare/1.0.6...1.0.7) (2022-02-26)
### 🦊 CI/CD
* **GitHub:** Fix paths for pre-release assets. Automatically generate changelog from git history. ([6ef66d9](https://git.griefed.de/Griefed/VersionChecker/commit/6ef66d93b090767d05ddccb3b5ab524ab23de33b))
* **GitHub:** Fix paths for release assets. Automatically generate changelog from git history. ([c1fc6bd](https://git.griefed.de/Griefed/VersionChecker/commit/c1fc6bdd8629184c7811306953ae06c0a3d2f947))
* **GitHub:** Remove artifacts which aren't being produced anyway ([2b8505a](https://git.griefed.de/Griefed/VersionChecker/commit/2b8505ad67fb56599ef145868a2dab9ddd1c24ae))
### 🛠 Fixes
* Fix regression bug introduced during last fix. Correctly acquire latest version from repository and correctly compare against other versions, preventing false positives and premature availability messages. ([6cfcecf](https://git.griefed.de/Griefed/VersionChecker/commit/6cfcecf2d7936cc6dd515dcb2d8839b29ea04286))
### Other
* **deps:** update dependency ghcr.io/griefed/baseimage-ubuntu-jdk-8 to v2.0.6 ([f903116](https://git.griefed.de/Griefed/VersionChecker/commit/f90311660e53e839cd88a366e35da8fcf7e75f88))
* **deps:** update dependency ghcr.io/griefed/gitlab-ci-cd to v2.0.3 ([b560503](https://git.griefed.de/Griefed/VersionChecker/commit/b5605032a9669f4f70fdfcac0d5712ac58894667))
### [1.0.6](https://git.griefed.de/Griefed/VersionChecker/compare/1.0.5...1.0.6) (2022-02-24)
......
# Simple semantic version checker for GitHub and GitLab
[![Homepage](https://img.shields.io/badge/Griefed.de-Homepage-c0ffee?style=for-the-badge&labelColor=325358&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAACylBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f39/f3+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v6OsnIvAAAA7XRSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiQlJicoKSorLC0uLzAxMjU2Nzg5Ojs8Pj9AQUJERUZHSElLTE9QUVJTVFVWV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Fj+5sgBbtxbyCx3on79f52rP/+12iVvMCPHGp8TIRNS/22hI40xLku9XTxel37LMDUPCvGKP6k4n708FEvdyJlgEYqis2tmhE+dGDZr/dl0KxR8f3KqN49yCTyAkg7kVLNvgHh72YViAd9Z81JMLcakAp+bkFM+RbCsMxLn1Wnism1Hjh/YsSp2ZMtqjIjq7LW+9SWnqrzODjCQijFGPxiC71Ynp/RJrZnjehzZ+Q9fNggLmTcf8AAAAABJRU5ErkJggg==)](https://www.griefed.de)
[![Blog](https://img.shields.io/badge/Griefed.de-Blog-c0ffee?style=for-the-badge&labelColor=325358&logo=wordpress)](https://blog.griefed.de)
[![Fleet](https://img.shields.io/badge/Griefed.de-Fleet-c0ffee?style=for-the-badge&labelColor=325358&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABiVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8XJWL///8gNCTuAAAAgXRSTlMAAgMEBQYHCAkLDA4PEBESFhgZGh0eISIlKC8zNDU3OT0+P0BBQkhKS01QU1RVVltcXWJjZGlrbG1wcnN0eHl6e4CBhYyOkJWWmZ6foaKkqaqsrrKztLe8vsHExcbHy8zNz9DT1NXX2Nna293e3+Tm5+nq7O3u7/Hy9fb4+fr7/f4zgtRAAAABWklEQVR42mKgHhCFMbg0dHW1xNGlBcw5wTS7tkcJoNV5UJItBoMA3GPjcm3btm3btq1+8s1JxijuV0p+X5NzVcfNRoT4O26ClEZykdydI5ddCHDt+EfqthiwYoXfRH++yb9r8IZ+o/CpeB1hE/zMtXf0KYKkP9p8ZSaCfq1S2ddDU84zrsuXYXZjYy0VcBxQKYVmgQ9slS8HhUbxSP+kNAPB+kIyO1ggr5mn9GoX70wKydA4/RNQQSVPvGspZEHQ5ZKHK5lu8UymUi/enRQuxYjcN5LPH+RTQfcVlQ4AbfJ1n4JKRusG0ErpzCn3vjFMe8g9/eUU2himHEAilc+Vq6XJ4Zyx6eXTk3f6/IOww7i2oOliXNXQ/H5kHBcWSO2MowyKJc4VU/BLOGcMm04EJF3FyHsQImkvMj/tQBhrz0to+rwSUf70XvjT23VWxKLLaBkYGuqr+Y8f9Q3q0fzzGED8cgAAAABJRU5ErkJggg==)](https://fleet.griefed.de)
[![GitHub](https://img.shields.io/badge/Griefed.de-Github-c0ffee?style=for-the-badge&labelColor=325358&logo=github)](https://github.com/Griefed)
[![DockerHub](https://img.shields.io/badge/Griefed.de-DockerHub-c0ffee?style=for-the-badge&labelColor=325358&logo=docker&logoColor=white)](https://hub.docker.com/u/griefed)
[![Discord](https://img.shields.io/badge/Griefed.de-Discord-c0ffee?style=for-the-badge&labelColor=325358&logo=discord&logoColor=white)](https://discord.griefed.de)
---
# Sources, GitHub, GitLab and Mirroring and all that good stuff
Repositories on GitHub are now for issues only. I've set up my own installation of GitLab and moved all my repositories over to [Git.Griefed.de](https://git.griefed.de/users/Griefed/projects). Make sure to check there first for the latest code before opening an issue on GitHub.
For questions, you can always join my [Discord server](https://discord.griefed.de) and talk to me there.
###### This repository is available at:
- Source: https://git.griefed.de/Griefed/VersionChecker
- Mirror: https://gitlab.com/Griefed/VersionChecker
- Mirror: https://github.com/Griefed/VersionChecker
- Mirror: https://gitea.com/Griefed/VersionChecker
---
[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/Griefed/VersionChecker?include_prereleases&label=Latest%20Release&logo=Github&style=for-the-badge&color=c0ffee&labelColor=325358)](https://github.com/Griefed/VersionChecker/releases/latest)
[![GitHub](https://img.shields.io/github/license/Griefed/VersionChecker?logo=GitHub&style=for-the-badge&color=c0ffee&labelColor=325358)](https://github.com/Griefed/VersionChecker/blob/main/LICENSE)
[![GitHub Repo stars](https://img.shields.io/github/stars/Griefed/VersionChecker?label=GitHub%20Stars&style=for-the-badge&logo=Github&labelColor=325358&color=c0ffee)](https://github.com/Griefed/VersionChecker)
[![GitHub forks](https://img.shields.io/github/forks/Griefed/VersionChecker?label=GitHub%20Forks&style=for-the-badge&logo=Github&labelColor=325358&color=c0ffee)](https://github.com/Griefed/VersionChecker)
[![GitHub contributors](https://img.shields.io/github/contributors/Griefed/VersionChecker?color=c0ffee&label=Contributors&logo=GitHub&logoColor=white&style=for-the-badge&labelColor=325358)](https://github.com/Griefed/VersionChecker/graphs/contributors)
[![GitHub all releases](https://img.shields.io/github/downloads/Griefed/VersionChecker/total?color=c0ffee&logo=GitHub&logoColor=white&labelColor=325358&style=for-the-badge)](https://github.com/Griefed/VersionChecker/releases)
[[_TOC_]]
A simple version checker, using semantic-release formats like 1.2.3, 2.3.4 or 6.6.6, as well as 3.4.5-alpha.2 or 4.5.6-beta.3,
for a given GitHub user and repository, or GitLab instance and project ID.
......
/*
* MIT License
*
* Copyright (c) 2022 Griefed
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package de.griefed.versionchecker;
public enum Comparison {
EQUAL,
NEW,
EQUAL_OR_NEW
}
......@@ -92,106 +92,100 @@ public abstract class VersionChecker {
private String isUpdateAvailable(@NotNull String currentVersion, boolean checkForPreReleases) {
if (checkForPreReleases) {
if (isNewBetaAvailable(currentVersion)) return latestBeta();
if (isNewBetaAvailable(currentVersion)) {
return latestBeta();
}
if (isNewAlphaAvailable(currentVersion)) return latestAlpha();
if (isNewAlphaAvailable(currentVersion)) {
return latestAlpha();
}
}
if (isNewSemanticVersion(currentVersion, latestVersion(checkForPreReleases))) return latestVersion(checkForPreReleases);
if (compareSemantics(currentVersion, latestVersion(checkForPreReleases), Comparison.NEW)) {
return latestVersion(checkForPreReleases);
}
return "up_to_date";
}
/**
* Check the given current version against the given new version whether the new version is actually newer.
* Compare the given new version against the given current version, depending on comparison type <code>EQUAL</code>,
* <code>NEW</code>, or <code>EQUAL_OR_NEW</code>.
* Checks are performed with the semantic release-formatting, e.g. 1.2.3, 2.3.4, 6.6.6
* @author Griefed
* @param currentVersion String. Current version to check against <code>newVersion</code>.
* @param newVersion String. New version to check against <code>currentVersion</code>.
* @param comparison {@link Comparison} Comparison level. Either <code>EQUAL</code>, <code>NEW</code>, or <code>EQUAL_OR_NEW</code>.
* @return Boolean. Returns <code>true</code> if the new version is indeed newer than the current version. Otherwise
* <code>false</code>.
* @throws NumberFormatException Thrown if the passed <code>currentVersion</code> or <code>newVersion</code> can not be
* parsed into integers.
*/
private boolean isNewSemanticVersion(@NotNull String currentVersion, @NotNull String newVersion) throws NumberFormatException {
protected boolean compareSemantics(@NotNull String currentVersion, @NotNull String newVersion, @NotNull Comparison comparison) {
LOG.debug("Current version: " + currentVersion);
LOG.debug("New version: " + newVersion);
LOG.debug("New version: " + newVersion);
LOG.debug("Comparison: " + comparison);
if (newVersion.equals("no_release")) return false;
if (newVersion.equals("no_release")) {
return false;
}
int newMajor,newMinor,newPatch,currentMajor,currentMinor,currentPatch;
String[] currentVersionSemantics = currentVersion.split("\\.");
String[] newVersionSemantics = newVersion.split("\\.");
List<Integer> currentSemantics = getSemantics(currentVersion);
List<Integer> newSemantics = getSemantics(newVersion);
currentMajor = Integer.parseInt(currentVersionSemantics[0]);
currentMinor = Integer.parseInt(currentVersionSemantics[1]);
if (currentVersionSemantics[2].contains("-")) {
currentMajor = currentSemantics.get(0);
currentMinor = currentSemantics.get(1);
currentPatch = currentSemantics.get(2);
currentPatch = Integer.parseInt(currentVersionSemantics[2].split("-")[0]);
newMajor = newSemantics.get(0);
newMinor = newSemantics.get(1);
newPatch = newSemantics.get(2);
} else {
switch (comparison) {
currentPatch = Integer.parseInt(currentVersionSemantics[2]);
case EQUAL:
return checkEqual(newMajor,newMinor,newPatch,currentMajor,currentMinor,currentPatch);
}
case NEW:
return checkNew(newMajor,newMinor,newPatch,currentMajor,currentMinor,currentPatch);
newMajor = Integer.parseInt(newVersionSemantics[0]);
newMinor = Integer.parseInt(newVersionSemantics[0]);
if (newVersionSemantics[2].contains("-")) {
newPatch = Integer.parseInt(newVersionSemantics[2].split("-")[0]);
} else {
newPatch = Integer.parseInt(newVersionSemantics[0]);
}
case EQUAL_OR_NEW:
return checkNewOrEqual(newMajor,newMinor,newPatch,currentMajor,currentMinor,currentPatch);
default:
LOG.error("Incorrect comparison type selected: " + comparison);
return false;
return checkNew(newMajor,newMinor,newPatch,currentMajor,currentMinor,currentPatch);
}
}
/**
* Check the given current version against the given new version whether the new version is actually newer or the same.
* Checks are performed with the semantic release-formatting, e.g. 1.2.3, 2.3.4, 6.6.6
* Acquire the version numbers of a semantic-formatted version.
* @author Griefed
* @param currentVersion String. Current version to check against <code>newVersion</code>.
* @param newVersion String. New version to check against <code>currentVersion</code>.
* @return Boolean. Returns <code>true</code> if the new version is newer than or the same as the current version. Otherwise
* <code>false</code>.
* @throws NumberFormatException Thrown if the passed <code>currentVersion</code> or <code>newVersion</code> can not be
* parsed into integers.
* @param version String. The version from which to acquire the version numbers.
* @return Integer List. List of version numbers. Major index 0, minor index 1, patch index 2.
*/
private boolean isNewOrSameSemanticVersion(@NotNull String currentVersion, @NotNull String newVersion) throws NumberFormatException {
LOG.debug("Current version: " + currentVersion);
LOG.debug("New version: " + newVersion);
private List<Integer> getSemantics(String version) {
List<Integer> semantics = new ArrayList<>(3);
if (newVersion.equals("no_release")) return false;
String[] versionNumbers = version.split("\\.");
int newMajor,newMinor,newPatch,currentMajor,currentMinor,currentPatch;
String[] currentVersionSemantics = currentVersion.split("\\.");
String[] newVersionSemantics = newVersion.split("\\.");
semantics.add(0,Integer.parseInt(versionNumbers[0]));
semantics.add(1,Integer.parseInt(versionNumbers[1]));
if (versionNumbers[2].contains("-")) {
currentMajor = Integer.parseInt(currentVersionSemantics[0]);
currentMinor = Integer.parseInt(currentVersionSemantics[1]);
if (currentVersionSemantics[2].contains("-")) {
currentPatch = Integer.parseInt(currentVersionSemantics[2].split("-")[0]);
semantics.add(2,Integer.parseInt(versionNumbers[2].split("-")[0]));
} else {
currentPatch = Integer.parseInt(currentVersionSemantics[2]);
semantics.add(2,Integer.parseInt(versionNumbers[2]));
}
newMajor = Integer.parseInt(newVersionSemantics[0]);
newMinor = Integer.parseInt(newVersionSemantics[0]);
if (newVersionSemantics[2].contains("-")) {
newPatch = Integer.parseInt(newVersionSemantics[2].split("-")[0]);
} else {
newPatch = Integer.parseInt(newVersionSemantics[0]);
}
return checkNewOrSame(newMajor,newMinor,newPatch,currentMajor,currentMinor,currentPatch);
return semantics;
}
/**
......@@ -206,11 +200,11 @@ public abstract class VersionChecker {
* @return Boolean. True if a new version was determined.
*/
private boolean checkNew(int newMajor, int newMinor, int newPatch, int currentMajor, int currentMinor, int currentPatch) {
if (newMajor > currentMajor && newMinor == currentMinor && newPatch == currentPatch) {
if (newMajor > currentMajor) {
// new major update
return true;
} else if (newMajor == currentMajor && newMinor > currentMinor && newPatch == currentPatch) {
} else if (newMajor == currentMajor && newMinor > currentMinor) {
// new minor update
return true;
......@@ -229,20 +223,25 @@ public abstract class VersionChecker {
* @param currentMajor Integer. The old versions major number.
* @param currentMinor Integer. The old versions minor number.
* @param currentPatch Integer. The old versions patch number.
* @return Boolean. True if a new version was determined.
* @return Boolean. True if a new or equal version was determined.
*/
private boolean checkNewOrSame(int newMajor, int newMinor, int newPatch, int currentMajor, int currentMinor, int currentPatch) {
if (newMajor >= currentMajor && newMinor == currentMinor && newPatch == currentPatch) {
// new major update
return true;
} else if (newMajor == currentMajor && newMinor >= currentMinor && newPatch == currentPatch) {
// new minor update
return true;
private boolean checkNewOrEqual(int newMajor, int newMinor, int newPatch, int currentMajor, int currentMinor, int currentPatch) {
return newMajor >= currentMajor && newMinor >= currentMinor && newPatch >= currentPatch;
}
// new patch update if true
} else
return newMajor == currentMajor && newMinor == currentMinor && newPatch >= currentPatch;
/**
* Compare two versions against each other and determine whether they are the same semantic versions.
* @author Griefed
* @param newMajor Integer. The new versions major number.
* @param newMinor Integer. The new versions minor number.
* @param newPatch Integer. The new versions patch number.
* @param currentMajor Integer. The old versions major number.
* @param currentMinor Integer. The old versions minor number.
* @param currentPatch Integer. The old versions patch number.
* @return Boolean. True if the versions are the same.
*/
private boolean checkEqual(int newMajor, int newMinor, int newPatch, int currentMajor, int currentMinor, int currentPatch) {
return newMajor == currentMajor && newMinor == currentMinor && newPatch == currentPatch;
}
/**
......@@ -256,18 +255,29 @@ public abstract class VersionChecker {
private boolean isNewAlphaAvailable(@NotNull String currentVersion) throws NumberFormatException {
// If no alpha releases are available, do not check for new alpha release.
if (latestAlpha().equals("no_alphas")) return false;
if (latestAlpha().equals("no_alphas")) {
return false;
}
String latestAlpha = latestAlpha();
if (compareSemantics(currentVersion, latestAlpha, Comparison.EQUAL) && currentVersion.contains("beta")) {
return false;
}
// Check if the given version is older than the latest alpha version by checking semantically. (1.2.3, 2.3.4, 6.6.6)
if (isNewSemanticVersion(currentVersion, latestAlpha)) return true;
if (compareSemantics(currentVersion, latestAlpha, Comparison.NEW)) {
return true;
if (currentVersion.contains("-")) {
} else if (compareSemantics(currentVersion, latestAlpha, Comparison.EQUAL_OR_NEW) && currentVersion.contains("-")) {
// If a new alpha, say alpha.5 for the given, say alpha.1, is available, return true.
return isPreReleaseNewer(currentVersion, latestAlpha);
} else {
return false;
}
}
......@@ -282,17 +292,24 @@ public abstract class VersionChecker {
private boolean isNewBetaAvailable(@NotNull String currentVersion) throws NumberFormatException {
// If no beta releases are available, do not check for new beta release.
if (latestBeta().equals("no_betas")) return false;
if (latestBeta().equals("no_betas")) {
return false;
}
String latestBeta = latestBeta();
// Check if the given version is older than the latest beta version by checking semantically. (1.2.3, 2.3.4, 6.6.6)
if (isNewSemanticVersion(currentVersion, latestBeta)) return true;
if (compareSemantics(currentVersion, latestBeta, Comparison.NEW)) {
return true;
} else if (compareSemantics(currentVersion, latestBeta, Comparison.EQUAL_OR_NEW) && currentVersion.contains("-")) {
if (currentVersion.contains("-")) {
// If a new beta, say beta.5 for the given, say beta.1, is available, return true.
return isPreReleaseNewer(currentVersion, latestBeta);
} else {
return false;
}
}
......@@ -387,7 +404,7 @@ public abstract class VersionChecker {
for (String betaVersion : betaVersions) {
if (isNewOrSameSemanticVersion(beta, betaVersion) && isPreReleaseNewer(beta, betaVersion)) {
if (compareSemantics(beta, betaVersion, Comparison.EQUAL_OR_NEW) && isPreReleaseNewer(beta, betaVersion)) {
beta = betaVersion;
}
}
......@@ -416,7 +433,7 @@ public abstract class VersionChecker {
for (String alphaVersion : alphaVersions) {
if (isNewOrSameSemanticVersion(alpha, alphaVersion) && isPreReleaseNewer(alpha, alphaVersion)) {
if (compareSemantics(alpha, alphaVersion, Comparison.EQUAL_OR_NEW) && isPreReleaseNewer(alpha, alphaVersion)) {
alpha = alphaVersion;
}
}
......
......@@ -24,6 +24,7 @@
package de.griefed.versionchecker.github;
import com.fasterxml.jackson.databind.JsonNode;
import de.griefed.versionchecker.Comparison;
import org.jetbrains.annotations.NotNull;
import de.griefed.versionchecker.VersionChecker;
import org.apache.logging.log4j.LogManager;
......@@ -106,7 +107,7 @@ public class GitHubChecker extends VersionChecker {
LOG.debug("All versions: " + versions);
// In case the given repository does not have any releases
if (versions == null || versions.size() == 0) {
if (versions.size() == 0) {
return null;
}
......@@ -114,7 +115,7 @@ public class GitHubChecker extends VersionChecker {
}
/**
* Get the latest regular release.
* Get the latest regular release, or pre-release if <code>checkForPreRelease</code> is <code>true</code>.
* @author Griefed
* @param checkForPreRelease Boolean. Whether to include alpha and beta releases for latest release versions.
* @return String. Returns the latest regular release. If no regular release is available, <code>no_release</code> is returned.
......@@ -122,14 +123,25 @@ public class GitHubChecker extends VersionChecker {
@Override
public String latestVersion(boolean checkForPreRelease) {
if (latest != null) {
LOG.debug("Latest version:" + latest);
return latest.get("tag_name").asText();
}
if (checkForPreRelease) {
if (!latestBeta().equals("no_betas")) return latestBeta();
String version = latest.get("tag_name").asText();
if (checkForPreRelease) {
String alpha = latestAlpha();
String beta = latestBeta();
if (!beta.equals("no_betas") && compareSemantics(version, beta, Comparison.NEW)) {
version = beta;
}
if (!latestAlpha().equals("no_alphas")) return latestAlpha();
if (!alpha.equals("no_alphas") && compareSemantics(version, alpha, Comparison.NEW)) {
version = alpha;
}
}
LOG.debug("Latest version:" + latest);
return version;
}
return "no_release";
......
......@@ -24,6 +24,7 @@
package de.griefed.versionchecker.gitlab;
import com.fasterxml.jackson.databind.JsonNode;
import de.griefed.versionchecker.Comparison;
import org.jetbrains.annotations.NotNull;
import de.griefed.versionchecker.VersionChecker;
import org.apache.logging.log4j.LogManager;
......@@ -103,7 +104,7 @@ public class GitLabChecker extends VersionChecker {
LOG.debug("All versions: " + versions);
// In case the given repository does not have any releases
if (versions == null || versions.size() == 0) {
if (versions.size() == 0) {
return null;
}
......@@ -119,17 +120,51 @@ public class GitLabChecker extends VersionChecker {
@Override
public String latestVersion(boolean checkForPreRelease) {
for (String version : getAllVersions()) {
LOG.debug("version: " + version);
if (!version.contains("alpha") && !version.contains("beta")) {
return version;
if (getAllVersions() != null) {
String latest = null;
if (checkForPreRelease) {
latest = getAllVersions().get(0);
} else {
for (String version : getAllVersions()) {
if (!version.contains("alpha") && !version.contains("beta")) {
latest = version;
break;
}
}
}
}
if (checkForPreRelease) {
if (!latestBeta().equals("no_betas")) return latestBeta();
if (latest == null) {
return "no_release";
}
for (String version : getAllVersions()) {
LOG.debug("version: " + version);
if (!version.contains("alpha") && !version.contains("beta") && compareSemantics(latest, version, Comparison.NEW)) {
latest = version;
}
}
if (checkForPreRelease) {
String alpha = latestAlpha();
String beta = latestBeta();
if (!beta.equals("no_betas") && compareSemantics(latest, beta, Comparison.NEW)) {
latest = beta;
}
if (!alpha.equals("no_alphas") && compareSemantics(latest, alpha, Comparison.NEW)) {
latest = alpha;
}
}
if (!latestAlpha().equals("no_alphas")) return latestAlpha();
return latest;
}
return "no_release";
......