Skip to content

Commit

Permalink
Smarter version bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Feb 21, 2024
1 parent 568175a commit 04f6782
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,23 @@ public final String obtain() {
if (fileVersion.equals(lastTagVersion)) {
if (!lastTagHash.equals(getParameters().getCommitHash().get())) {
var noMetaParts = version.toString().split("-");
var noBuildParts = noMetaParts[0].split("\\+");
var mainParts = noBuildParts[0].split("\\.");
int lastMetaNumber = 0;
for (int i = 0; i < noMetaParts.length; i++) {
if (noMetaParts[i].matches(".*\\.\\d+.*")) {
lastMetaNumber = i;
}
}
var noBuildParts = noMetaParts[lastMetaNumber].split("\\+");
int lastBuildNumber = 0;
for (int i = 0; i < noBuildParts.length; i++) {
if (noBuildParts[i].matches(".*\\.\\d+.*")) {
lastBuildNumber = i;
}
}
var mainParts = noBuildParts[lastBuildNumber].split("\\.");
mainParts[mainParts.length-1] = Integer.toString(Integer.parseInt(mainParts[mainParts.length-1])+1);
noBuildParts[0] = String.join(".", mainParts);
noMetaParts[0] = String.join("+", noBuildParts);
noBuildParts[lastBuildNumber] = String.join(".", mainParts);
noMetaParts[lastMetaNumber] = String.join("+", noBuildParts);
version = new StringBuilder(String.join("-", noMetaParts));
}
}
Expand Down

0 comments on commit 04f6782

Please sign in to comment.