Skip to content
Merged

Dev #409

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
50 changes: 50 additions & 0 deletions .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: reusable-build
on:
workflow_call:
outputs:
artifact-name:
description: "Name of the uploaded build artifact"
value: ${{ jobs.build.outputs.artifact-name }}

jobs:
build:
name: Build Project
runs-on: ubuntu-latest
outputs:
artifact-name: ${{ steps.upload.outputs.artifact-name }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'microsoft'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

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

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build/libs/
53 changes: 3 additions & 50 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,7 @@
# Build Workflow

name: Build & test

on:
pull_request:

concurrency:
group: ${{ github.head_ref || format('{0}-{1}', github.ref, github.run_number) }}
cancel-in-progress: true

permissions:
contents: read
on: [ pull_request ]

jobs:
build:
name: Build

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 10

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
**/loom-cache
**/prebundled-jars
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Chmod Gradle
run: chmod +x ./gradlew

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

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dev-artifacts
path: build/libs/
build:
uses: ./.github/workflows/build_reusable.yml
55 changes: 16 additions & 39 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
name: Publish Mod
on:
workflow_dispatch:
inputs:
mod-version:
description: 'Mod version:'
required: true
on: [workflow_dispatch] # Manual trigger

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'

- name: Build
run: ./gradlew build

- name: Publish
uses: Kir-Antipov/mc-publish@v3.3
with:
name: Redstone Tools ${{ github.event.inputs.mod-version }}
permissions:
contents: write

modrinth-id: 9ySQVrz2
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

# curseforge-id: 849609
# curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

github-tag: ${{ github.event.inputs.mod-version }}
github-generate-changelog: false
github-token: ${{ secrets.RELEASE_TOKEN }}

files-primary: build/libs/redstonetools-${{ github.event.inputs.mod-version }}.jar
files-secondary: ''
jobs:
build:
runs-on: ubuntu-22.04
container:
image: mcr.microsoft.com/openjdk/jdk:21-ubuntu
options: --user root
steps:
- uses: actions/checkout@v4
- run: ./gradlew build publishMods
env:
# modrinth-id: 9ySQVrz2
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
78 changes: 67 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
plugins {
id 'fabric-loom' version '1.10-SNAPSHOT'
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.+'
id "me.modmuss50.mod-publish-plugin" version "1.1.0"
}

version = project.mod_version
version = project.mod_version + "+" + stonecutter.current.version
group = project.maven_group

base {
Expand All @@ -22,6 +23,25 @@ loom {
}
}

stonecutter {
swaps["mouse_clicked_params"] = eval(current.version, "<1.21.10") ? "double mouseX, double mouseY, int button" : "Click click, boolean doubleClick" // mouseClicked
swaps["mouse_clicked_args"] = eval(current.version, "<1.21.10") ? "mouseX, mouseY, button" : "click, doubleClick"
swaps["on_mouse_clicked_args"] = eval(current.version, "<1.21.10") ? "(int) mouseX, (int) mouseY, button" : "click, doubleClick" // onMouseClicked
swaps["dragged_released_params"] = eval(current.version, "<1.21.10") ? "double mouseX, double mouseY, int button" : "Click click" // mouseDragged, mouseReleased
swaps["dragged_released_args"] = eval(current.version, "<1.21.10") ? "mouseX, mouseY, button" : "click"
swaps["on_released_args"] = eval(current.version, "<1.21.10") ? "(int) mouseX, (int) mouseY, button" : "click" // onMouseReleased
swaps["keyinput_params"] = eval(current.version, "<1.21.10") ? "int keyCode, int scanCode, int modifiers" : "KeyInput input" // keyPressed, keyReleased
swaps["keyinput_args"] = eval(current.version, "<1.21.10") ? "keyCode, scanCode, modifiers" : "input"
swaps["charinput_params"] = eval(current.version, "<1.21.10") ? "char chr, int modifiers" : "CharInput input" // charTyped
swaps["charinput_args"] = eval(current.version, "<1.21.10") ? "chr, modifiers" : "input"
swaps["click_and_inputs_imports"] = eval(current.version, "<1.21.10") ? "" :
"//\nimport net.minecraft.client.gui.Click;\nimport net.minecraft.client.input.KeyInput;\nimport net.minecraft.client.input.CharInput;"

swaps["get_x"] = eval(current.version, "<1.21.10") ? "x" : "getX()"
swaps["get_y"] = eval(current.version, "<1.21.10") ? "y" : "getY()"
swaps["get_width"] = eval(current.version, "<1.21.10") ? "entryWidth" : "getWidth()"
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
Expand Down Expand Up @@ -68,6 +88,18 @@ dependencies {
modApi "maven.modrinth:malilib:${project.malilib_version}"
}

loom {
decompilerOptions.named("vineflower") {
options.put("mark-corresponding-synthetics", "1") // Adds names to lambdas - useful for mixins
}

runConfigs.configureEach {
ideConfigGenerated(true)
// vmArgs("-Dmixin.debug.export=true") // Exports transformed classes for debugging
runDir = "../../run" // Shares the run directory between versions
}
}

processResources {
inputs.property "version", project.version
inputs.property "minecraft_version", project.minecraft_version
Expand All @@ -77,31 +109,45 @@ processResources {
filteringCharset "UTF-8"

filesMatching("fabric.mod.json") {
expand "version": project.version,
expand(
"version": project.version,
"minecraft_version": project.minecraft_version,
"minecraft_version_out": project.minecraft_version_out,
"malilib_version": project.minecraft_version_out,
"loader_version": project.loader_version
)
}
}

tasks.register("collectFile") {
group = "build"
mustRunAfter("build")

doLast {
// println "build/libs/${project.archives_base_name}-${project.mod_version}+${project.minecraft_version}.jar"
copy {
from file("build/libs/${project.archives_base_name}-${project.mod_version}+${project.minecraft_version}.jar")
into rootProject.file("build/libs")
}
}
}

def targetJavaVersion = 21
tasks.register("buildAndCollect") {
group = "build"
dependsOn(tasks.named("build"), tasks.named("collectFile"))
}

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release.set(targetJavaVersion)
}
it.options.release.set(21)
}

java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
toolchain.languageVersion = JavaLanguageVersion.of(21)
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
Expand Down Expand Up @@ -130,4 +176,14 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

publishMods {
github {
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = "RedstoneTools/redstonetools-mod"
commitish = "main"
tagName = "v${project.mod_version}"
allowEmptyFiles = true
}
}
19 changes: 2 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,5 @@ org.gradle.parallel=true
maven_group = tools.redstone
archives_base_name = redstonetools

loader_version=0.16.10
mod_version = v3.1.3

minecraft_version=1.21.8
minecraft_version_out=1.21.8
yarn_mappings=1.21.8+build.1

fabric_version=0.130.0+1.21.8
malilib_version=0.25.4
worldedit_version=1.21.7:7.3.15
#minecraft_version=1.21.4
#minecraft_version_out=1.21.4
#yarn_mappings=1.21.4+build.8
#
#fabric_version=0.119.3+1.21.4
#malilib_version=0.23.1
#worldedit_version=1.21.4:7.3.10
loader_version=0.17.3
mod_version = v3.1.4
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 26 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()

maven {url = "https://maven.fabricmc.net/"}
maven {
name = "KikuGie Snapshots"
url = "https://maven.kikugie.dev/snapshots"
}
}
}

rootProject.name = "redstonetools-mod"
plugins {
id "dev.kikugie.stonecutter" version "0.7.10"
}

rootProject.name = "redstonetools-mod"

include "1.21.4"
include "1.21.5"
include "1.21.8"
include "1.21.10"

stonecutter {
kotlinController = false
centralScript = "build.gradle"

create(rootProject) {
versions "1.21.4", "1.21.5", "1.21.8", "1.21.10"
vcsVersion = "1.21.10"
}
}
Loading