Add auto version generator
[no changelog]
This commit is contained in:
@@ -183,7 +183,7 @@ tasks.test {
|
|||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
version = rootProject.property("mod_version").toString()
|
version = getGitTagInfo()
|
||||||
group = rootProject.property("maven_group").toString()
|
group = rootProject.property("maven_group").toString()
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
|||||||
31
buildSrc/src/lookupversion.kt
Normal file
31
buildSrc/src/lookupversion.kt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
fun execString(vararg args: String): String {
|
||||||
|
val pb = ProcessBuilder(*args)
|
||||||
|
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||||
|
.start()
|
||||||
|
pb.waitFor()
|
||||||
|
return pb.inputStream.readAllBytes().decodeToString().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val tag = "([0-9.]+)\\.0".toRegex()
|
||||||
|
private val tagOffset = "([0-9.]+)\\.0-([0-9]+)..+".toRegex()
|
||||||
|
|
||||||
|
inline fun <T> Regex.useMatcher(string: String, block: (MatchResult) -> T): T? {
|
||||||
|
return matchEntire(string)?.let(block)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGitTagInfo(): String {
|
||||||
|
val str = execString("git", "describe", "--tags", "HEAD")
|
||||||
|
tag.useMatcher(str) {
|
||||||
|
return it.groupValues[0]
|
||||||
|
}
|
||||||
|
tagOffset.useMatcher(str) {
|
||||||
|
return it.groupValues[1] + "." + it.groupValues[2]
|
||||||
|
}
|
||||||
|
return "nogitversion"
|
||||||
|
}
|
||||||
@@ -121,11 +121,8 @@ echo -n "Choosing next version as: "
|
|||||||
read newversion
|
read newversion
|
||||||
echo "Confirming new version as $newversion"
|
echo "Confirming new version as $newversion"
|
||||||
|
|
||||||
echo Editing gradle.properties
|
|
||||||
sed -i -E 's/(mod_version *= *).*/\1'"$newversion"'/' "$basedir"/gradle.properties
|
|
||||||
git add gradle.properties
|
|
||||||
echo Committing release commit
|
echo Committing release commit
|
||||||
git commit -m 'Prepare release '"$newversion"'
|
git commit --allow-empty -m 'Prepare release '"$newversion"'
|
||||||
|
|
||||||
[no changelog]'
|
[no changelog]'
|
||||||
echo Tagging release commit
|
echo Tagging release commit
|
||||||
|
|||||||
@@ -7,6 +7,5 @@ org.gradle.jvmargs=-Xmx4096M
|
|||||||
loom.platform=fabric
|
loom.platform=fabric
|
||||||
|
|
||||||
archives_base_name=Firmament
|
archives_base_name=Firmament
|
||||||
mod_version=1.8.0
|
|
||||||
maven_group=moe.nea.firmament
|
maven_group=moe.nea.firmament
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user