-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle.kts
29 lines (26 loc) · 927 Bytes
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.time.LocalDateTime
import java.time.format.DateTimeFormatterBuilder
import java.time.format.SignStyle
import java.time.temporal.ChronoField
allprojects {
this.project.version = System.getenv("GITHUB_REF_NAME")?.substringAfter('v') ?: dateAsVersion()
repositories {
mavenCentral()
}
}
fun dateAsVersion(): String {
val formatter = DateTimeFormatterBuilder()
.appendValue(ChronoField.YEAR, 4, 4, SignStyle.NEVER)
.appendLiteral('.')
.appendValue(ChronoField.MONTH_OF_YEAR, 2)
.appendLiteral('.')
.appendValue(ChronoField.DAY_OF_MONTH, 2)
.appendLiteral('-')
.appendValue(ChronoField.HOUR_OF_DAY, 2)
.appendLiteral('.')
.appendValue(ChronoField.MINUTE_OF_HOUR, 2)
.appendLiteral('.')
.appendValue(ChronoField.SECOND_OF_MINUTE, 2)
.toFormatter()
return LocalDateTime.now().format(formatter)
}