Skip to content

Commit

Permalink
Build: new version code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Aug 7, 2024
1 parent 0d18029 commit 1a22bcd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gradle/git-tag-version.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ ext.getVersionCodeFromTags = { ->
try {
def code = new ByteArrayOutputStream()
exec {
commandLine 'git', 'tag', '--list'
commandLine 'git', 'rev-list', '--count', 'HEAD'
standardOutput = code
}
return 14 + code.toString().split("\n").size()
def now = ZonedDateTime.now(ZoneId.of("UTC"))
def year = String.format("%02d", now.year % 100)
def month = String.format("%02d", now.monthValue)
def day = String.format("%02d", now.dayOfMonth)
def revisions = String.format("%02d", code.toString().trim().toInteger() % 100)
def version = String.format("%s%s%s%s", year, month, day, revisions).toInteger()
return version
}
catch (ignored) {
return -1
Expand Down

0 comments on commit 1a22bcd

Please sign in to comment.