Skip to content

Commit

Permalink
Release 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JvstvsHD committed Sep 15, 2024
1 parent 3c3be57 commit 910f842
Show file tree
Hide file tree
Showing 26 changed files with 546 additions and 383 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
java-version: '21'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@88425854a36845f9c881450d9660b5fd46bee142
uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6
- name: Build
run: ./gradlew build --stacktrace
- name: Publish
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ necrify-api/build
necrify-common/build
necrify-paper/build
necrify-velocity/build
necrify-velocity/run
necrify-velocity/run
**/.kotlin/**
20 changes: 9 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import com.diffplug.gradle.spotless.SpotlessPlugin
import io.papermc.hangarpublishplugin.model.Platforms
import net.kyori.indra.licenser.spotless.IndraSpotlessLicenserPlugin
import org.gradle.kotlin.dsl.internal.sharedruntime.codegen.licenseHeader
import java.util.*

plugins {
`maven-publish`
signing
id("io.papermc.hangar-publish-plugin") version "0.1.2"
id("com.gradleup.shadow") version "8.3.0" apply false
id("com.gradleup.shadow") version "8.3.1" apply false
id("net.kyori.indra.licenser.spotless") version "2.2.0"
java
}

group = "de.jvstvshd.necrify"
version = "1.2.0"
group = Version.PROJECT_GROUP
version = Version.PROJECT_VERSION

subprojects {
apply {
Expand Down Expand Up @@ -54,7 +52,7 @@ subprojects {
publishing {
repositories {
maven(
if (project.version.toString().endsWith("-SNAPSHOT"))
if (project.publishingVersion().endsWith("-SNAPSHOT"))
"https://s01.oss.sonatype.org/content/repositories/snapshots/" else "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
) {
name = "ossrh"
Expand All @@ -73,7 +71,7 @@ subprojects {
from(this@subprojects.components["java"])
groupId = rootProject.group.toString().lowercase(Locale.getDefault())
artifactId = project.name
version = project.version.toString()
version = project.publishingVersion()

pom {
name.set(project.name)
Expand Down Expand Up @@ -109,13 +107,13 @@ subprojects {
hangarPublish {
publications.register("necrify") {
version.set(buildVersion())
channel.set(if (!isRelease()) "Snapshot" else "Release")
channel.set(if (!rootProject.isRelease) "Snapshot" else "Release")
id.set("necrify")
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
if (!isRelease()) {
apiKey.set(System.getenv("HANGAR_API_TOKEN") ?: "")
if (!rootProject.isRelease) {
changelog.set(changelogMessage())
} else {
changelog.set("Changes will be provided shortly.\nComplete changelog can be found on GitHub: https://www.github.com/JvstvsHD/necrify/releases/tag/v$version")
changelog.set("Changes will be provided shortly.\nComplete changelog can be found on GitHub: https://www.github.com/JvstvsHD/necrify/releases/tag/v${rootProject.version}")
}
platforms {
register(Platforms.PAPER) {
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
plugins {
kotlin("jvm") version "2.0.0"
kotlin("jvm") version "2.0.20"
`kotlin-dsl`
}

group = "de.jvstvshd.necrify"
version = "1.2.0-SNAPSHOT"
/*group = Version.PROJECT_GROUP
version = Version.PROJECT_VERSION*/

repositories {
mavenCentral()
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation(platform("org.junit:junit-bom:5.11.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
}

Expand Down
35 changes: 35 additions & 0 deletions buildSrc/src/main/kotlin/Git.kt
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)
68 changes: 28 additions & 40 deletions buildSrc/src/main/kotlin/Version.kt
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")
23 changes: 12 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
[versions]
velocity-api = "3.3.0-SNAPSHOT"
luckperms-api = "5.4"
jackson-databind = "2.17.1"
jackson-datatype-jsr310 = "2.13.4"
jackson-yaml = "2.13.4"
postgresql = "42.5.0"
hikari = "5.0.1"
jackson-databind = "2.17.2"
jackson-datatype-jsr310 = "2.17.2"
jackson-yaml = "2.17.2"
postgresql = "42.7.4"
hikari = "5.1.0"
sadu = "2.2.1"
junit = "5.9.1"
junit = "5.11.0"
paper-api = "1.20.6-R0.1-SNAPSHOT"
brigadier = "1.0.500"
mariadb = "3.4.1"
mysql = "9.0.0"
adventure = "4.17.0"
cloud = "2.0.0-SNAPSHOT"
cloud = "2.0.0"
cloud-minecraft = "2.0.0-beta.10"
eventbus = "3.3.1"
jetbrains-annotations = "24.1.0"
slf4j = "2.0.13"
slf4j = "2.0.16"
minecraftdependencydownload = "1.0.0"

[libraries]
Expand Down Expand Up @@ -51,9 +52,9 @@ adventure-text-serializer-plain = { group = "net.kyori", name = "adventure-text-
# Cloud
cloud-core = { group = "org.incendo", name = "cloud-core", version.ref = "cloud" }
cloud-annotations = { group = "org.incendo", name = "cloud-annotations", version.ref = "cloud" }
cloud-velocity = { group = "org.incendo", name = "cloud-velocity", version.ref = "cloud" }
cloud-minecraft-extras = { group = "org.incendo", name = "cloud-minecraft-extras", version.ref = "cloud" }
cloud-brigadier = { group = "org.incendo", name = "cloud-brigadier", version.ref = "cloud" }
cloud-velocity = { group = "org.incendo", name = "cloud-velocity", version.ref = "cloud-minecraft" }
cloud-minecraft-extras = { group = "org.incendo", name = "cloud-minecraft-extras", version.ref = "cloud-minecraft" }
cloud-brigadier = { group = "org.incendo", name = "cloud-brigadier", version.ref = "cloud-minecraft" }

# Testing
junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
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
Loading

0 comments on commit 910f842

Please sign in to comment.