Skip to content
Merged
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
29 changes: 10 additions & 19 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,22 @@ jobs:
- name: Make gradle wrapper executable
run: chmod +x ./gradlew

- name: Append short Git commit hash to version
run: |
SHORT_HASH=$(git rev-parse --short HEAD)
CURRENT_VERSION=$(grep '^mod_version=' gradle.properties | cut -d= -f2)
sed -i "s/^mod_version=.*/mod_version=${CURRENT_VERSION}+$SHORT_HASH/" gradle.properties

- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build --no-daemon

- name: Set JAR name
id: binary-version
- name: Get version
id: jars
run: |
MOD_ID=$(grep '^mod_id=' gradle.properties | cut -d= -f2)
MOD_VERSION=$(grep '^mod_version=' gradle.properties | cut -d= -f2)
MC_VERSION=$(grep '^minecraft_version=' gradle.properties | cut -d= -f2)
JAR_NAME="MadeInAbyss-${MOD_VERSION}-mc${MC_VERSION}"
echo "jar_name=$JAR_NAME" >> "$GITHUB_OUTPUT"

- name: Rename output JAR
run: |
ORIG_JAR=$(ls build/libs/*.jar | head -n 1)
NEW_NAME="build/libs/${{ steps.binary-version.outputs.jar_name }}.jar"
mv "$ORIG_JAR" "$NEW_NAME"
SHORT_HASH=$(git rev-parse --short HEAD)

echo "mod_id=$MOD_ID" >> $GITHUB_OUTPUT
echo "mod_version=$MOD_VERSION" >> $GITHUB_OUTPUT
echo "short_hash=$SHORT_HASH" >> $GITHUB_OUTPUT

- name: Upload Mod JAR
uses: actions/upload-artifact@v7
with:
name: ${{ steps.binary-version.outputs.jar_name }}
name: ${{ steps.jars.outputs.mod_id }}-${{ steps.jars.outputs.mod_version }}+${{ steps.jars.outputs.short_hash }}
path: build/libs/*.jar
45 changes: 45 additions & 0 deletions .github/workflows/ci-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI (Publish)
on:
workflow_dispatch:
inputs:
release:
description: 'Publish'
required: false
default: false
type: boolean

jobs:
build:
runs-on: ubuntu-latest
env:
RELEASE: ${{ inputs.release }}

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
cache: gradle

- name: Make gradle wrapper executable
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew build --no-daemon

- name: Run game tests
id: game_test
run: ./gradlew runGameTestServer --no-daemon

#TODO: Modrinth and CurseForge
- name: Publish
if: ${{ inputs.release }}
env:
# MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
# CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishMods
191 changes: 92 additions & 99 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,57 @@ plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.1.21'
id 'net.kyori.blossom' version '2.2.0'
id 'me.modmuss50.mod-publish-plugin' version '1.1.0'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4.1'
}

tasks.named('wrapper', Wrapper).configure {
distributionType = Wrapper.DistributionType.BIN
}

def release = providers.environmentVariable("RELEASE")
boolean dev = !release.map { it.toBoolean() }.getOrElse(false)

def gitHash = providers.exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
}.standardOutput.asText.map { it.trim() }.getOrElse("dev")

version = mod_version
group = mod_group_id

repositories {
mavenLocal()

// Jade
maven {
name = "Jade"
url = "https://api.modrinth.com/maven"
}
// EMI
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}
// JEI
maven {
name = "Jared's maven"
url = "https://maven.blamejared.com/"
}
// Curios
maven {
name = "Curios"
url = uri("https://maven.theillusivec4.top/")
}
// Patchouli
maven {
name = "Vazkii's Maven"
url 'https://maven.blamejared.com'
}
// Simple Bedrock Model
maven {
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
// KubeJS
maven {
name = "KubeJS"
url "https://maven.latvian.dev/releases"
content {
includeGroup "dev.latvian.mods"
includeGroup "dev.latvian.apps"
}
}
maven {
url 'https://jitpack.io'
content {
includeGroup "com.github.rtyley"
}
}
// Create
maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" }
maven { url = "https://maven.createmod.net" }
maven { url = "https://api.modrinth.com/maven" } // Jade
maven { url = "https://maven.terraformersmc.com/" } // EMI
maven { url = "https://maven.blamejared.com/" } // JEI, Patchouli
maven { url = "https://maven.theillusivec4.top/" } // Curios
maven { url = "https://api.modrinth.com/maven" } // Simple Bedrock Model
maven { url = "https://maven.latvian.dev/releases" } // KubeJS
maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // Ponder
maven { url = "https://maven.createmod.net" } // Ponder, Flywheel
maven { url = "https://jitpack.io" }
maven { url = "https://maven.firstdark.dev/snapshots" } // LDLib2
}

base {
archivesName = mod_id
version = mod_version + (dev && gitHash != null ? "+${gitHash}" : "")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java.withSourcesJar()
java.withJavadocJar()

minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')

runs {
// applies to all the run configs below
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'

// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
systemProperty 'forge.logging.console.level', 'debug'

modSource project.sourceSets.main
}

client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

Expand All @@ -103,72 +62,94 @@ runs {
argument '--nogui'
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

data {
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
sourceSets.main {
resources {
srcDir 'src/generated/resources'
exclude '**/.cache'
}
blossom.javaSources {
property 'version', mod_version
property 'gitCommit', gitHash
}
}

jar {
manifest {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_authors,
'Specification-Version' : project.jar.archiveVersion,
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestampe' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : minecraft_version,
"MixinConfigs" : "mia.mixins.json",
"Git-Hash" : gitHash
])
}
}

javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}

tasks.named("sourcesJar", Jar) {
manifest.attributes([
"Git-Hash": gitHash
])
}

// Sets up a dependency configuration called 'localRuntime'.
// This configuration should be used instead of 'runtimeOnly' to declare
// a dependency that will be present for runtime testing but that is
// "optional", meaning it will not be pulled by dependents of this mod.
configurations {
runtimeClasspath.extendsFrom localRuntime
}

dependencies {
implementation "net.neoforged:neoforge:${neo_version}"

// Curios
compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"

// Simple Bedrock Model
implementation jarJar("maven.modrinth:simplebedrockmodel:$sbm_version")
compileOnly "com.maydaymemory:mae:$mae_version"

// JEI
compileOnly("mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}")
runtimeOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}")
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"

// EMI
compileOnly "dev.emi:emi-neoforge:${emi_version}:api"
runtimeOnly "dev.emi:emi-neoforge:${emi_version}"

// Curios
compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"

// Patchouli
compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}:api"
runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}"

// Jade
implementation "maven.modrinth:jade:${project.jade_version}"

// Simple Bedrock Model
implementation jarJar("maven.modrinth:simplebedrockmodel:$sbm_version")
compileOnly("com.maydaymemory:mae:$mae_version")
implementation "maven.modrinth:jade:${jade_version}"

// KubeJS
api("dev.latvian.mods:kubejs-neoforge:$kubejs_version")
api "dev.latvian.mods:kubejs-neoforge:$kubejs_version"

// Ponder
implementation("net.createmod.ponder:ponder-neoforge:${ponder_version}+mc${minecraft_version}")
compileOnly("dev.engine-room.flywheel:flywheel-neoforge-api-${minecraft_version}:${flywheel_version}")
runtimeOnly("dev.engine-room.flywheel:flywheel-neoforge-${minecraft_version}:${flywheel_version}")
implementation "net.createmod.ponder:ponder-neoforge:${ponder_version}+mc${minecraft_version}"
compileOnly "dev.engine-room.flywheel:flywheel-neoforge-api-${minecraft_version}:${flywheel_version}"
runtimeOnly "dev.engine-room.flywheel:flywheel-neoforge-${minecraft_version}:${flywheel_version}"
}

// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : minecraft_version,
Expand All @@ -190,7 +171,6 @@ tasks.withType(ProcessResources).configureEach {
}
}

// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
register('mavenJava', MavenPublication) {
Expand All @@ -204,11 +184,24 @@ publishing {
}
}

publishMods {
file = jar.archiveFile
type = ALPHA
version = "$mod_version+mc$minecraft_version"
displayName = "$mod_name $mod_version for mc$minecraft_version"
modLoaders.add("neoforge")

github {
repository = "MIA-Development-Team/Made-In-Abyss"
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = gitHash
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
options.encoding = 'UTF-8'
}

// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ neogradle.subsystems.parchment.minecraftVersion=1.21.1
neogradle.subsystems.parchment.mappingsVersion=2024.11.17

minecraft_version=1.21.1
minecraft_version_range=[1.21.1, 1.22)
neo_version=21.1.211
minecraft_version_range=[1.21, 1.21.1)
neo_version=21.1.224
loader_version_range=[1,)

jei_version=19.27.0.340
Expand Down
6 changes: 6 additions & 0 deletions src/main/java-templates/com/altnoir/mia/MiaBuildInfo.java.peb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.altnoir.mia;

public class MiaBuildInfo {
public static final String VERSION = "{{ version }}";
public static final String GIT_COMMIT = "{{ gitCommit | default("unknown") }}";
}
Loading
Loading