Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build (jdk 17)
name: Build snapshot

on:
push:
Expand All @@ -7,32 +7,26 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup Temurin 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache/Uncache
uses: actions/cache@v3
uses: actions/checkout@v6

- name: Setup Temurin 25
uses: actions/setup-java@v5
with:
path: |
~/.gradle/caches
~/.gradle/loom-cache
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
java-version: 25
distribution: temurin

- name: Build
run: ./gradlew build --stacktrace --warning-mode fail

- name: Upload build artifacts
continue-on-error: true
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: Artifacts
path: build/libs/
- name: Publish to the snapshots maven repo
run: ./gradlew publishAllPublicationsToUkuSnapshotsRepository
name: ukulib-artifacts
path: build/libs/*.jar

- name: Publish to the maven repo
run: ./gradlew publishAllPublicationsToUkuRepository
env:
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
ORG_GRADLE_PROJECT_mavenUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenPassword: ${{ secrets.MAVEN_PASSWORD }}
24 changes: 15 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release
name: Release new version

on:
release:
Expand All @@ -9,16 +9,22 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup Temurin 21
uses: actions/setup-java@v4
- name: Checkout sources
uses: actions/checkout@v6

- name: Setup Temurin 25
uses: actions/setup-java@v5
with:
java-version: 21
java-version: 25
distribution: temurin
- name: Checkout sources
uses: actions/checkout@v4

- name: Publish to the maven repo
run: ./gradlew publish
run: ./gradlew publishAllPublicationsToUkuRepository -Pbuild.release=true
env:
ORG_GRADLE_PROJECT_mavenUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenPassword: ${{ secrets.MAVEN_PASSWORD }}

- name: Publish to modrinth
run: ./gradlew modrinth -Pbuild.release=true
env:
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
PUBLISH_RELEASE: owo
137 changes: 3 additions & 134 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,135 +1,4 @@
plugins {
id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT"
id("io.freefair.lombok") version "9.1.0"

id("maven-publish")
id("com.modrinth.minotaur") version "2.8.10"
}

version = "${project.property("mod_version")}+${project.property("minecraft_version")}${getVersionMetadata()}"
group = project.property("maven_group") as String

val archiveName = project.property("archives_base_name") as String

if (System.getenv().containsKey("PUBLISH_RELEASE")) {
tasks.publish.get().finalizedBy("modrinth")
}

repositories {
maven {
url = uri("https://maven.uku3lig.net/releases")
}
maven {
url = uri("https://maven.terraformersmc.com/releases/")
}
}

dependencies {
// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")

include(implementation("com.moandjiezana.toml:toml4j:${project.property("toml4j_version")}")!!)

include(modImplementation(fabricApi.module("fabric-resource-loader-v1", project.property("fabric_version") as String))!!)
include(modImplementation(fabricApi.module("fabric-command-api-v2", project.property("fabric_version") as String))!!)
include(modImplementation(fabricApi.module("fabric-key-binding-api-v1", project.property("fabric_version") as String))!!)

// optional deps
modCompileOnly("com.terraformersmc:modmenu:${project.property("modmenu_version")}")
}

base {
archivesName = archiveName
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

withSourcesJar()
withJavadocJar()
}

tasks.processResources {
inputs.property("version", version)
filteringCharset = "UTF-8"

filesMatching("fabric.mod.json") {
expand("version" to version)
}
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}

tasks.jar {
from("LICENSE") {
rename { "${it}_${archiveName}" }
}
}

tasks.javadoc {
exclude(
"net/uku3lig/ukulib/config/impl/UkulibConfig.java",
"net/uku3lig/ukulib/config/option/widget/TextInputWidget.java",
"net/uku3lig/ukulib/mixin/*"
)
}

publishing {
publications {
register<MavenPublication>("mavenJava") {
from(components.getByName("java"))
}
}

repositories {
maven {
name = "UkuReleases"
url = uri("https://maven.uku3lig.net/releases")
credentials {
username = "uku"
password = System.getenv("MAVEN_PASSWORD")
}
}
maven {
name = "UkuSnapshots"
url = uri("https://maven.uku3lig.net/snapshots")
credentials {
username = "uku"
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}

var releaseType = "release"
if (version.toString().contains("alpha")) releaseType = "alpha"
else if (version.toString().contains("beta")) releaseType = "beta"

modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "Y8uFrUil"
versionNumber = project.version.toString()
versionType = releaseType
uploadFile.set(tasks.remapJar) // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions.add(project.property("minecraft_version") as String) // Must be an array, even with only one version
loaders.addAll("fabric", "quilt")
changelog = "See https://github.com/uku3lig/ukulib/releases/tag/${project.version}"
}

fun getVersionMetadata(): String {
if (System.getenv().containsKey("PUBLISH_RELEASE")) return ""

val buildId = System.getenv("GITHUB_RUN_NUMBER")

// CI builds only
return if (buildId != null) {
"-build.${buildId}"
} else {
"-local"
}
}
id("net.fabricmc.fabric-loom") version "1.15-SNAPSHOT" apply false
id("net.neoforged.moddev") version "2.0.140" apply false
}
14 changes: 14 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "2.3.0"
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation("com.modrinth.minotaur:com.modrinth.minotaur.gradle.plugin:2.8.10")
implementation("org.ow2.asm:asm:9.9.1")
}
34 changes: 34 additions & 0 deletions buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import org.gradle.api.Project

object BuildConfig {
const val MINECRAFT_VERSION: String = "26.1-snapshot-5"
const val FABRIC_LOADER_VERSION: String = "0.18.4"
const val FABRIC_API_VERSION: String = "0.143.0+26.1"
const val NEOFORGE_VERSION: String = "26.1.0.0-alpha.8+snapshot-4"

const val TOML4J_VERSION: String = "0.7.2"
const val MODMENU_VERSION: String = "18.0.0-alpha.5"

const val MOD_VERSION: String = "2.0.0-alpha.1"

const val MODRINTH_PROJECT_ID: String = "Y8uFrUil"

fun createVersionString(project: Project): String {
val builder = StringBuilder()

val isReleaseBuild = project.hasProperty("build.release")
val buildId = System.getenv("GITHUB_RUN_NUMBER")

builder.append(MOD_VERSION).append("+").append(MINECRAFT_VERSION)

if (!isReleaseBuild) {
if (buildId != null) {
builder.append("-build.${buildId}")
} else {
builder.append("-local")
}
}

return builder.toString()
}
}
62 changes: 62 additions & 0 deletions buildSrc/src/main/kotlin/multiloader-base.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
plugins {
id("java-library")
id("idea")
id("maven-publish")
}

group = "net.uku3lig"
version = BuildConfig.createVersionString(project)

base {
archivesName = rootProject.name + "-" + project.name
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(25)

withSourcesJar()
withJavadocJar()
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(25)
}

tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = false
}

repositories {
mavenCentral()
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group as String
artifactId = rootProject.name + "-" + project.name
version = version

from(components["java"])
}
}

repositories {
val isReleaseBuild = project.hasProperty("build.release")
val mavenUsername: String? by project // reads from ORG_GRADLE_PROJECT_mavenUsername
val mavenPassword: String? by project // reads from ORG_GRADLE_PROJECT_mavenPassword

maven {
name = "Uku"
url = uri("https://maven.uku3lig.net".let {
if (isReleaseBuild) "$it/releases" else "$it/snapshots"
})

credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}
Loading