Skip to content

Commit

Permalink
First version?
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Dec 14, 2024
1 parent 738c277 commit 5912a4c
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 34 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# REQUIRES DATAGEN TO BE CALLED IN A JOB BEFORE THIS!!

name: Publish

on:
workflow_call:
inputs:
version:
required: true
type: string

jobs:
publish:
name: Publish Code as Github Package - ${{ inputs.version }}
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

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

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

- name: Publish
run: ./gradlew :publish
env:
VERSION: ${{ inputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/ci-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Continuous Integration

env:
GH_PKG_URL: "https://maven.pkg.github.com/${{ github.repository }}"

on:
workflow_dispatch:
push:
paths-ignore:
- "README.md"
- "LICENSE"
- ".github/**/*"
- "**/*.gradle.kts"
- "**/gradle.properties"

jobs:
vars:
name: Get Variables
runs-on: ubuntu-22.04
outputs:
version: ${{steps.version.outputs.version}}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 150
fetch-tags: true

- name: Version
id: version
uses: paulhatch/[email protected]
with:
version_format: "${major}.${minor}.${patch}"
search_commit_body: true
bump_each_commit: true

publish:
needs: [vars]
uses: ./.github/workflows/_publish.yml
secrets: inherit
with:
version: ${{ needs.vars.outputs.version }}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ public interface GanderConstants {
JvmVendorSpec JAVA_VENDOR = IS_CI ? JvmVendorSpec.ADOPTIUM : JvmVendorSpec.JETBRAINS;

String MINECRAFT_VERSION = "1.20.1";
String MINECRAFT_VERSION_SHORT = MINECRAFT_VERSION.substring("1.".length());

String FORGE_VERSION = MINECRAFT_VERSION + "-47.3.12";

String PARCHMENT_VERSION = MINECRAFT_VERSION;
String PARCHMENT_MAPPINGS = "2023.09.03";

String GROUP = "dev.compactmachines";
String VERSION = MINECRAFT_VERSION_SHORT + ".0";
}
55 changes: 26 additions & 29 deletions buildSrc/src/main/kotlin/gander-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import dev.compactmachines.GanderConstants
import org.slf4j.event.Level

var envVersion: String = System.getenv("VERSION") ?: "9.9.9"
if (envVersion.startsWith("v"))
envVersion = envVersion.trimStart('v')

plugins {
id("java-library")
id("idea")
id("org.jetbrains.gradle.plugin.idea-ext")
id("net.neoforged.moddev.legacyforge")
id("maven-publish")
}

// main convention script which sets up a basic MDG workspace
// pulling in version data from GanderConstants since version catalogs
// from the main outer project are not accessible here

group = GanderConstants.GROUP
version = GanderConstants.VERSION

base {
archivesName = project.name
group = "dev.compactmods.gander"
version = envVersion

libsDirectory.convention(rootProject.layout.projectDirectory.dir("libs/${project.name}"))
}

Expand Down Expand Up @@ -61,31 +66,6 @@ neoForge {
publish(atFile)
}
}

runs.configureEach {
// set up basic common run config properties
// due to using convention this can be override in each run config
logLevel.convention(Level.DEBUG)
sourceSet.convention(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
loadedMods.convention(mods) // all registered mods
gameDirectory.convention(type.map { layout.projectDirectory.dir("run/$it") })

// using '.map' adds args as a 'provider'
// making them lazily evaluated later
// when 'type' actually exists
//
// adds jbr jvm args only for client/server run types
jvmArguments.addAll(type.map {
if(GanderConstants.IS_CI || (it != "client" && it != "server"))
return@map emptyList<String>()

return@map listOf(
"-XX:+AllowEnhancedClassRedefinition",
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:+AllowRedefinitionToAddDeleteMethods"
)
})
}
}

tasks.jar {
Expand All @@ -97,7 +77,6 @@ dependencies {
// does not affect runtime or production
// safe to have at compile time with no issues
compileOnly("org.jetbrains:annotations:26.0.1")

annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
}

Expand All @@ -114,3 +93,21 @@ javaToolchains.compilerFor {
languageVersion.convention(GanderConstants.JAVA_VERSION)
vendor.convention(GanderConstants.JAVA_VENDOR)
}

val PACKAGES_URL = System.getenv("GH_PKG_URL") ?: "https://maven.pkg.github.com/compactmods/gander"
publishing {
publications.register<MavenPublication>(project.name) {
from(components.getByName("java"))
}

repositories {
// GitHub Packages
maven(PACKAGES_URL) {
name = "GitHubPackages"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
2 changes: 2 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
val isRelease: Boolean = (System.getenv("RELEASE") ?: "false").equals("true", true)

plugins {
id("gander-convention")
}
98 changes: 97 additions & 1 deletion testmod/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
import dev.compactmachines.GanderConstants
import gradle.kotlin.dsl.accessors._53f21c2e2286c58eadab8fd2d7f5601a.*
import org.slf4j.event.Level

var envVersion: String = System.getenv("VERSION") ?: "9.9.9"
if (envVersion.startsWith("v"))
envVersion = envVersion.trimStart('v')

plugins {
id("gander-convention")
id("java-library")
id("idea")
id("org.jetbrains.gradle.plugin.idea-ext")
id("net.neoforged.moddev.legacyforge")
id("maven-publish")
}

// main convention script which sets up a basic MDG workspace
// pulling in version data from GanderConstants since version catalogs
// from the main outer project are not accessible here

base {
archivesName = project.name
group = "dev.compactmods.gander"
version = envVersion

libsDirectory.convention(rootProject.layout.projectDirectory.dir("libs/${project.name}"))
}

javaToolchains.compilerFor {
languageVersion.convention(GanderConstants.JAVA_VERSION)
vendor.convention(GanderConstants.JAVA_VENDOR)
}

// sets up MDG workspace and includes all other gander modules
Expand All @@ -13,6 +42,27 @@ val gModules = listOf(
gModules.map { it.path }.forEach(::evaluationDependsOn)

neoForge {
version = GanderConstants.FORGE_VERSION
// not currently usable since the AT included in legacy forge
// does not itself validate, many unused/nonexistent AT entries exist in it
// validateAccessTransformers.convention(true)

parchment {
minecraftVersion = GanderConstants.PARCHMENT_VERSION
mappingsVersion = GanderConstants.PARCHMENT_MAPPINGS
}

// apply this modules AT file if it exists
// also mark for publishing with maven publication
val atFile = file("src/main/resources/META-INF/accesstransformer.cfg")

if(atFile.exists()) {
accessTransformers {
from(atFile)
publish(atFile)
}
}

mods {
create(SourceSet.MAIN_SOURCE_SET_NAME) {
sourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
Expand All @@ -33,6 +83,31 @@ neoForge {
}

runs {
configureEach {
// set up basic common run config properties
// due to using convention this can be override in each run config
logLevel = Level.DEBUG
sourceSet = sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]
loadedMods = mods // all registered mod
gameDirectory = type.map { layout.projectDirectory.dir("run/$it") }

// using '.map' adds args as a 'provider'
// making them lazily evaluated later
// when 'type' actually exists
//
// adds jbr jvm args only for client/server run types
jvmArguments.addAll(type.map {
if(GanderConstants.IS_CI || (it != "client" && it != "server"))
return@map emptyList<String>()

return@map listOf(
"-XX:+AllowEnhancedClassRedefinition",
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:+AllowRedefinitionToAddDeleteMethods"
)
})
}

create("client") {
client()
}
Expand Down Expand Up @@ -61,3 +136,24 @@ mixin {
config("gander_render.mixins.json")
config("gander_levels.mixins.json")
}

tasks.jar {
manifest.from(file("src/main/resources/META-INF/MANIFEST.MF"))
}


dependencies {
// not included with MDG currently
// does not affect runtime or production
// safe to have at compile time with no issues
compileOnly("org.jetbrains:annotations:26.0.1")
annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"

if(!GanderConstants.IS_CI) {
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "9000"))
}
}

0 comments on commit 5912a4c

Please sign in to comment.