From 06da7338b1086f4527c940220e03df28cc878148 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 4 Dec 2021 15:41:26 +0200 Subject: [PATCH] Publish to modrinth when a new release is built --- .github/workflows/gradle-publish.yml | 9 ++++++++- build.gradle | 29 +++++++++++++++++++++++++++- gradle.properties | 5 +++++ settings.gradle | 4 ++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 2744841f..4885ef6f 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -1,4 +1,4 @@ -name: Publish To Maven +name: Publish on: push: tags: @@ -25,3 +25,10 @@ jobs: uses: eskatos/gradle-command-action@v1 with: arguments: build publish + - name: Publish Modrinth Jar + env: + MODRINTH_KEY: ${{ secrets.MODRINTH_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: eskatos/gradle-command-action@v1 + with: + arguments: publishModrinth diff --git a/build.gradle b/build.gradle index 4a091407..0fe764ab 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,16 @@ +buildscript { + dependencies { + classpath 'com.github.dexman545:Outlet:1.2.0' + } +} plugins { id 'java-library' id 'fabric-loom' version '0.10-SNAPSHOT' id 'maven-publish' + id 'com.modrinth.minotaur' version '1.1.0' id 'org.ajoberstar.reckon' version '0.13.0' } +apply plugin: 'dex.plugins.outlet' java { toolchain { @@ -11,6 +18,9 @@ java { } } +outlet.allowSnapshotsForProject = false +outlet.mcVersionRange = project.minecraft_version_range + group = project.group description = project.displayname archivesBaseName = project.name @@ -102,6 +112,23 @@ task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource } +import com.modrinth.minotaur.TaskModrinthUpload +task publishModrinth (type: TaskModrinthUpload){ + onlyIf { + def stage = version.version.stage.value + stage != null && stage.name != 'beta' + } + + token = System.env.MODRINTH_KEY + projectId = project.modrinth_project_id + versionNumber = version.toString() + uploadFile = jar.outputs.getFiles().asPath // This is the java jar task + addLoader(project.modrinth_loader_type) + outlet.mcVersions().each{ver -> + addGameVersion ver + } +} + publishing { publications { maven(MavenPublication) { @@ -109,7 +136,7 @@ publishing { pom { name = "MineLittlePony" - description = "HD Skins support for Minecraft" + description = "Ponify your Minecraft experience!" url = "https://minelittlepony-mod.com" licenses { license { diff --git a/gradle.properties b/gradle.properties index 88c61e25..257290ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,6 +14,11 @@ org.gradle.daemon=false authors=Verdana, Rene_Z, Mumfrey, Killjoy1221, Sollace description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings. +# Publishing + minecraft_version_range=>=1.18 + modrinth_loader_type=fabric + modrinth_project_id=JBjInUXM + # Dependencies modmenu_version=2.0.0-beta.7 kirin_version=1.10.0 diff --git a/settings.gradle b/settings.gradle index b0b0b064..3f1fa950 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,6 +5,10 @@ pluginManagement { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + maven { + name = 'Jitpack' + url = 'https://jitpack.io' + } gradlePluginPortal() } }