Gradle: Get version name from git tag
This commit is contained in:
parent
9431b6356b
commit
08a1b1cf77
31
build.gradle
31
build.gradle
|
@ -1,4 +1,5 @@
|
|||
import com.modrinth.minotaur.TaskModrinthUpload
|
||||
import com.modrinth.minotaur.request.VersionType
|
||||
|
||||
plugins {
|
||||
id "java"
|
||||
|
@ -8,7 +9,7 @@ plugins {
|
|||
id "maven-publish"
|
||||
id "fabric-loom" version "0.10-SNAPSHOT" apply false
|
||||
id "com.matthewprenger.cursegradle" version "1.4.0"
|
||||
id "com.modrinth.minotaur" version "1.1.0"
|
||||
id "com.modrinth.minotaur" version "1.2.1"
|
||||
id "org.ajoberstar.grgit" version "3.1.0"
|
||||
}
|
||||
|
||||
|
@ -18,8 +19,24 @@ ext.isPublicMaven = project.hasProperty('publicMaven')
|
|||
// Fetch changelog
|
||||
grgit.open(dir: project.projectDir.toString())
|
||||
def tagList = grgit.tag.list()
|
||||
def changelogStr = "Commits in this release:"
|
||||
for (def commit : grgit.log{range(tagList.get(tagList.size() - 2).fullName, tagList.get(tagList.size() - 1).fullName)}) {
|
||||
def currentTag = tagList.get(tagList.size() - 1)
|
||||
ext.currentVer = currentTag.getName()
|
||||
ext.currentType = VersionType.RELEASE
|
||||
switch (ext.currentVer[0]) {
|
||||
case 'v':
|
||||
ext.currentVer = ext.currentVer.substring(1)
|
||||
break
|
||||
case 'b':
|
||||
ext.currentVer = ext.currentVer.substring(1)
|
||||
ext.currentType = VersionType.BETA
|
||||
break
|
||||
case 'a':
|
||||
ext.currentVer = ext.currentVer.substring(1)
|
||||
ext.currentType = VersionType.ALPHA
|
||||
break
|
||||
}
|
||||
def changelogStr = "Commits in " + ext.currentType.toString().toLowerCase() + " " + ext.currentVer + ":"
|
||||
for (def commit : grgit.log{range(tagList.get(tagList.size() - 2).fullName, currentTag.fullName)}) {
|
||||
changelogStr += "\n- " + commit.shortMessage
|
||||
}
|
||||
println(changelogStr)
|
||||
|
@ -73,7 +90,7 @@ allprojects {
|
|||
}
|
||||
|
||||
group = "io.gitlab.jfronny.libjf"
|
||||
version = "$project.mod_version" + (project.hasProperty('pipeline') ? "-" + project.getProperty('pipeline') : "")
|
||||
version = "$rootProject.ext.currentVer" + (project.hasProperty('pipeline') ? "-" + project.getProperty('pipeline') : "")
|
||||
|
||||
sourceSets {
|
||||
testmod {
|
||||
|
@ -279,8 +296,9 @@ task modrinth(type: TaskModrinthUpload, dependsOn: build) {
|
|||
token = ENV.MODRINTH_API_TOKEN
|
||||
projectId = "WKwQAwke"
|
||||
versionNumber = version
|
||||
versionName = "[${project.minecraft_version}] ${project.mod_version}"
|
||||
versionName = "[${project.minecraft_version}] ${version}"
|
||||
uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")
|
||||
versionType = rootProject.ext.currentType
|
||||
changelog = changelogStr
|
||||
addGameVersion("${project.minecraft_version}")
|
||||
addLoader('fabric')
|
||||
|
@ -299,7 +317,8 @@ curseforge {
|
|||
addGameVersion "${project.minecraft_version}"
|
||||
changelog = changelogStr
|
||||
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
|
||||
mainArtifact.displayName = "[${project.minecraft_version}] ${project.mod_version}"
|
||||
mainArtifact.displayName = "[${project.minecraft_version}] ${version}"
|
||||
releaseType = rootProject.ext.currentType.toString().toLowerCase()
|
||||
afterEvaluate {
|
||||
uploadTask.dependsOn(build)
|
||||
}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/versions.html
|
||||
# https://fabricmc.net/versions.html
|
||||
minecraft_version=1.18-pre4
|
||||
yarn_mappings=build.9
|
||||
loader_version=0.12.5
|
||||
# Mod Properties
|
||||
mod_version=2.1.4
|
||||
maven_group=io.gitlab.jfronny
|
||||
archives_base_name=libjf
|
||||
|
||||
fabric_version=0.42.7+1.18
|
||||
|
|
Loading…
Reference in New Issue