Skip to content

Commit

Permalink
Experimental: auto-publish to Modrinth w/ Minotaur
Browse files Browse the repository at this point in the history
  • Loading branch information
3TUSK committed Dec 10, 2023
1 parent bac8e67 commit 3a01f10
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: auto-build
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Apply Cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: $${{ runner.os }}-gradle
- name: Build
id: build
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
MODRINTH_PROJECT_ID: ${{ secrets.MODRINTH_PROJECT_ID }}
run: ./gradlew build modrinth
38 changes: 29 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import java.time.Instant
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
plugins {
id 'com.modrinth.minotaur' version '2.+' apply false
}

interface PlatformInfoExtension {
// Which platform (i.e. Fabric/Forge/Quilt) is this implementation is on?
// In case of projects uses solely VanillaGradle, here we use 'Vanilla'.
Property<String> getPlatform();
// Which Minecraft version is this implementation based on?
Property<String> getMinecraftVersion();
// Which Minecraft version is this implementation compatible with?
ListProperty<String> getSupportedMinecraftVersions();
}

def mainVersion = '1.0.0'

subprojects { Project p ->
apply plugin: 'java'
apply plugin: 'com.modrinth.minotaur' // https://stackoverflow.com/a/50153617

p.extensions.create('platformInfo', PlatformInfoExtension)

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.withSourcesJar()

p.archivesBaseName = "ExampleMod"
p.version = "1.0.0"
p.archivesBaseName = "ExampleMultiProjectMod"
p.version = mainVersion

p.repositories {
// Enable maven central for all subprojects
Expand Down Expand Up @@ -55,7 +60,11 @@ subprojects { Project p ->
}
}

if (pAfter.extensions.findByName('loom')) {
def projectExt = pAfter.extensions.platformInfo as PlatformInfoExtension

def useLoom = pAfter.extensions.findByName('loom')

if (useLoom) {
pAfter.loom {
// Uncomment this if you have Mixin configurations
// mixin {
Expand All @@ -67,18 +76,29 @@ subprojects { Project p ->
}
}

def projectExt = pAfter.extensions.platformInfo as PlatformInfoExtension
pAfter.archivesBaseName += "-${projectExt.platform.get()}-${projectExt.minecraftVersion.get()}"

if ("Vanilla" != projectExt.platform.get()) {
pAfter.modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = System.getenv("MODRINTH_PROJECT_ID")
loaders = [ projectExt.platform.get().toLowerCase(Locale.ROOT) ]
gameVersions = projectExt.supportedMinecraftVersions.getOrElse([])
uploadFile = useLoom ? pAfter.remapJar : pAfter.jar
versionNumber = mainVersion
versionType = 'release' // alpha | beta | release
// TODO Declare Dependency
}
}

pAfter.jar {
manifest.attributes([
"Specification-Title": "Example-Mod",
"Specification-Vendor": "Whoever comes up with the spec of the mod",
"Specification-Version": "1.0",
"Implementation-Title": "${pAfter.archivesBaseName}",
"Implementation-Version": "${pAfter.version}",
"Implementation-Vendor": "Whoever actually writes the mod",
"Implementation-Timestamp": DateTimeFormatter.ISO_INSTANT.format(Instant.now().truncatedTo(ChronoUnit.SECONDS))
"Implementation-Vendor": "Whoever actually writes the mod"
])
}
}
Expand Down

0 comments on commit 3a01f10

Please sign in to comment.