-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
546 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import org.gradle.api.Project | ||
import java.io.ByteArrayOutputStream | ||
|
||
//https://docs.papermc.io/misc/hangar-publishing | ||
class Git(private val project: Project) { | ||
|
||
fun latestCommitMessage(): String { | ||
return project.git("log", "-1", "--pretty=%B") | ||
} | ||
|
||
fun latestCommitHash(): String { | ||
return project.git("rev-parse", "HEAD") | ||
} | ||
|
||
fun latestCommitHashShort(): String { | ||
return project.git("rev-parse", "--short", "HEAD") | ||
} | ||
|
||
fun currentBranch(): String { | ||
return project.git("rev-parse", "--abbrev-ref", "HEAD") | ||
} | ||
} | ||
|
||
fun Project.git(vararg command: String): String { | ||
val byteOut = ByteArrayOutputStream() | ||
project.exec { | ||
commandLine = listOf("git", *command) | ||
standardOutput = byteOut | ||
errorOutput = System.err | ||
} | ||
return byteOut.toString(Charsets.UTF_8.name()).trim() | ||
} | ||
|
||
val Project.git: Git | ||
get() = Git(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,43 @@ | ||
import org.gradle.api.Project | ||
import java.io.ByteArrayOutputStream | ||
|
||
class Version(val project: Project) { | ||
|
||
//https://docs.papermc.io/misc/hangar-publishing | ||
fun executeGitCommand(vararg command: String): String { | ||
val byteOut = ByteArrayOutputStream() | ||
project.exec { | ||
commandLine = listOf("git", *command) | ||
standardOutput = byteOut | ||
} | ||
return byteOut.toString(Charsets.UTF_8.name()).trim() | ||
} | ||
object Version { | ||
const val PROJECT_VERSION = "1.2.1" | ||
const val PROJECT_GROUP = "de.jvstvshd.necrify" | ||
} | ||
|
||
fun latestCommitMessage(): String { | ||
return executeGitCommand("log", "-1", "--pretty=%B") | ||
fun Project.buildNumber(): String? { | ||
if (hasProperty("buildnumber")) { | ||
return property("buildnumber").toString() | ||
} | ||
return System.getenv("GITHUB_RUN_NUMBER") | ||
} | ||
|
||
fun latestCommitHash(): String { | ||
return executeGitCommand("rev-parse", "HEAD") | ||
} | ||
fun Project.publishingVersion(): String { | ||
val branch = git.currentBranch() | ||
return if (branch == "master" || branch.startsWith("dev/")) { | ||
version.toString() | ||
} else "${branch.replace('/', '-')}-SNAPSHOT" | ||
} | ||
|
||
fun latestCommitHashShort(): String { | ||
return executeGitCommand("rev-parse", "--short", "HEAD") | ||
fun Project.buildVersion(): String { | ||
val versionString: String = project.version as String | ||
if (!project.isSnapshot) { | ||
return versionString | ||
} | ||
|
||
fun buildNumber(): String? { | ||
if (project.hasProperty("buildnumber")) { | ||
return project.property("buildnumber").toString() | ||
} | ||
return System.getenv("GITHUB_RUN_NUMBER") | ||
val buildNum = project.buildNumber() | ||
return if (buildNum != null) { | ||
"$versionString-$buildNum" | ||
} else { | ||
versionString | ||
} | ||
|
||
val versionString: String = project.version as String | ||
val isRelease: Boolean = !versionString.contains("-") | ||
val suffixedVersion: String = if (project.isSnapshot) versionString + | ||
if (project.hasProperty("buildnumber")) { | ||
"-" + project.property("buildnumber") as String | ||
} else { | ||
val githubRunNumber = System.getenv("GITHUB_RUN_NUMBER") | ||
if (githubRunNumber != null) "-$githubRunNumber" else "" | ||
} else versionString | ||
} | ||
|
||
fun Project.buildVersion() = Version(this).suffixedVersion | ||
|
||
fun Project.changelogMessage() = with(Version(this)) { | ||
"https://github.com/JvstvsHD/necrify/commit/${latestCommitHash()}: ${latestCommitMessage()}" | ||
fun Project.changelogMessage() = with(git) { | ||
"[https://github.com/JvstvsHD/necrify/commit/${latestCommitHash()}](${latestCommitHashShort()}: ${latestCommitMessage()}" | ||
} | ||
|
||
fun Project.isRelease() = Version(this).isRelease | ||
val Project.isRelease: Boolean | ||
get() = !version.toString().contains("-") | ||
|
||
val Project.isSnapshot: Boolean | ||
get() = version.toString().endsWith("-SNAPSHOT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.