From 26c61ae3c8e69eb51fc3a7b6fcc4aeeb540dccb2 Mon Sep 17 00:00:00 2001 From: RingLo_ <63995099+lonelyicer@users.noreply.github.com> Date: Wed, 8 Apr 2026 10:39:02 +0800 Subject: [PATCH 1/2] ci: new build work flow --- .github/workflows/ci-build.yml | 29 +-- build.gradle | 177 ++++++++---------- gradle.properties | 4 +- .../com/altnoir/mia/MiaBuildInfo.java.peb | 6 + src/main/java/com/altnoir/mia/MIA.java | 3 + .../resources/META-INF/neoforge.mods.toml | 22 +-- 6 files changed, 110 insertions(+), 131 deletions(-) create mode 100644 src/main/java-templates/com/altnoir/mia/MiaBuildInfo.java.peb diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index b340522b..d35bb17c 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -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 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3ff60740..3a8c07fd 100644 --- a/build.gradle +++ b/build.gradle @@ -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 } @@ -103,29 +62,55 @@ 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 } @@ -133,42 +118,38 @@ configurations { 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, @@ -190,7 +171,6 @@ tasks.withType(ProcessResources).configureEach { } } -// Example configuration to allow publishing using the maven-publish plugin publishing { publications { register('mavenJava', MavenPublication) { @@ -205,10 +185,9 @@ publishing { } 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 diff --git a/gradle.properties b/gradle.properties index 26d70cc8..28682fa7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java-templates/com/altnoir/mia/MiaBuildInfo.java.peb b/src/main/java-templates/com/altnoir/mia/MiaBuildInfo.java.peb new file mode 100644 index 00000000..f2d2ae1c --- /dev/null +++ b/src/main/java-templates/com/altnoir/mia/MiaBuildInfo.java.peb @@ -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") }}"; +} \ No newline at end of file diff --git a/src/main/java/com/altnoir/mia/MIA.java b/src/main/java/com/altnoir/mia/MIA.java index f6c1be00..b34be87a 100644 --- a/src/main/java/com/altnoir/mia/MIA.java +++ b/src/main/java/com/altnoir/mia/MIA.java @@ -19,12 +19,15 @@ @Mod(MIA.MOD_ID) public class MIA { public static final String MOD_ID = "mia"; + public static final String MOD_NAME = "Memento In Abyss"; public static final Logger LOGGER = LogUtils.getLogger(); public static final CurseManager CURSE_MANAGER = new CurseManager(); public static final AbyssTrialSpawnerManager SPAWNER_MANAGER = new AbyssTrialSpawnerManager(); public MIA(IEventBus modEventBus, ModContainer modContainer) { + LOGGER.info("{} {}+{} initializing...", MOD_NAME, MiaBuildInfo.VERSION, MiaBuildInfo.GIT_COMMIT); + modEventBus.addListener(this::commonSetup); MiaItems.register(modEventBus); diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index 3b8ebadd..8551af41 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -1,23 +1,23 @@ -modLoader="javafml" #mandatory -loaderVersion="${loader_version_range}" #mandatory +modLoader="javafml" +loaderVersion="${loader_version_range}" license="${mod_license}" -[[mods]] #mandatory -modId="${mod_id}" #mandatory -version="${mod_version}" #mandatory -displayName="${mod_name}" #mandatory +[[mods]] +modId="${mod_id}" +version="${mod_version}" +displayName="${mod_name}" logoFile = "mia.png" displayURL="https://github.com/MIA-Development-Team/Made-In-Abyss" #optional -authors="${mod_authors}" #optional +authors="${mod_authors}" description='''${mod_description}''' [[mixins]] config="${mod_id}.mixins.json" -[[dependencies.${mod_id}]] #optional - modId="neoforge" #mandatory - type="required" #mandatory - versionRange="[${neo_version},)" #mandatory +[[dependencies.${mod_id}]] + modId="neoforge" + type="required" + versionRange="[${neo_version},)" ordering="NONE" side="BOTH" From 431a19feb9953da48acf353ad3060c1e6d86cc03 Mon Sep 17 00:00:00 2001 From: RingLo_ <63995099+lonelyicer@users.noreply.github.com> Date: Wed, 8 Apr 2026 11:05:25 +0800 Subject: [PATCH 2/2] ci(feat): publish mod --- .github/workflows/ci-publish.yml | 45 ++++++++++++++++++++++++++++++++ build.gradle | 14 ++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/ci-publish.yml diff --git a/.github/workflows/ci-publish.yml b/.github/workflows/ci-publish.yml new file mode 100644 index 00000000..b29f16f6 --- /dev/null +++ b/.github/workflows/ci-publish.yml @@ -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 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3a8c07fd..50f211f9 100644 --- a/build.gradle +++ b/build.gradle @@ -184,6 +184,20 @@ 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' }