Skip to content

Commit 07a88af

Browse files
committed
[ci skip] update publishing
1 parent c7ec32c commit 07a88af

File tree

3 files changed

+231
-32
lines changed

3 files changed

+231
-32
lines changed

.github/workflows/release-tags.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14-
env:
15-
MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }}
16-
MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }}
1714
steps:
1815
- uses: actions/checkout@v2
1916
with:
@@ -47,5 +44,10 @@ jobs:
4744
title: "${{ env.RELEASE_VERSION }}"
4845
files: build/libs/*.jar
4946

50-
- name: Publish to maven
51-
run: ./gradlew publish
47+
- name: Publish to Maven, Modrinth, and CurseForge
48+
run: ./gradlew publish
49+
env:
50+
MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }}
51+
MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }}
52+
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
53+
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}

build.gradle

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1656003793falsepattern36
1+
//version: 1656003793falsepattern38
22
/*
33
DO NOT CHANGE THIS FILE!
44
@@ -9,6 +9,10 @@ Please check https://github.com/FalsePattern/ExampleMod1.7.10/blob/main/build.gr
99

1010
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
1111
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
12+
import com.matthewprenger.cursegradle.CurseArtifact
13+
import com.matthewprenger.cursegradle.CurseRelation
14+
import com.modrinth.minotaur.dependencies.ModDependency
15+
import com.modrinth.minotaur.dependencies.VersionDependency
1216
import org.gradle.internal.logging.text.StyledTextOutput.Style
1317
import org.gradle.internal.logging.text.StyledTextOutputFactory
1418

@@ -63,6 +67,8 @@ plugins {
6367
id 'com.palantir.git-version' version '0.13.0'
6468
id 'de.undercouch.download' version '5.0.1'
6569
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
70+
id 'com.modrinth.minotaur' version '2.+' apply false
71+
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
6672
}
6773
apply plugin: 'com.falsepattern.jtweaker'
6874

@@ -122,6 +128,12 @@ propertyDefaultIfUnset("mixinPreinitConfig", "")
122128
propertyDefaultIfUnset("remapStubs", false)
123129
propertyDefaultIfUnset("useObsoleteSpongeMixins", false)
124130

131+
propertyDefaultIfUnset("modrinthProjectId", "")
132+
propertyDefaultIfUnset("modrinthDependencies", "")
133+
propertyDefaultIfUnset("curseForgeProjectId", "")
134+
propertyDefaultIfUnset("curseForgeRelations", "")
135+
propertyDefaultIfUnset("changelog", "No changelog URL was provided.")
136+
125137
propertyDefaultIfUnset("remoteMappings", "https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/")
126138
propertyDefaultIfUnset("mappingsChannel", "stable")
127139
propertyDefaultIfUnset("mappingsVersion", "12")
@@ -704,6 +716,99 @@ publishing {
704716
}
705717
}
706718

719+
720+
if (curseForgeProjectId != "") {
721+
apply plugin: 'com.matthewprenger.cursegradle'
722+
curseforge {
723+
apiKey = System.getenv("CURSEFORGE_TOKEN") ?: ""
724+
project {
725+
id = curseForgeProjectId
726+
changelogType = "text"
727+
changelog = project.changelog.replace("{version}", modVersion)
728+
releaseType = modVersion.contains("-a") ? "alpha" : modVersion.contains("-b") ? "beta" : "release"
729+
addGameVersion project.minecraft.version
730+
mainArtifact(jar) {
731+
displayName = "$modName version: $modVersion"
732+
}
733+
}
734+
options {
735+
javaIntegration = false
736+
forgeGradleIntegration = false
737+
}
738+
}
739+
if (curseForgeRelations.size() != 0) {
740+
String[] deps = curseForgeRelations.split(";")
741+
deps.each { dep ->
742+
if (dep.size() == 0) {
743+
return
744+
}
745+
String[] parts = dep.split(":")
746+
String type = parts[0]
747+
String name = parts[1]
748+
addCurseForgeRelation(type, name)
749+
}
750+
}
751+
tasks.curseforge.dependsOn(build)
752+
tasks.publish.dependsOn(curseforge)
753+
}
754+
755+
if (modrinthProjectId != "") {
756+
apply plugin: 'com.modrinth.minotaur'
757+
modrinth {
758+
token = System.getenv("MODRINTH_TOKEN")
759+
projectId = modrinthProjectId
760+
versionNumber = modVersion
761+
versionType = modVersion.contains("-a") ? "alpha" : modVersion.contains("-b") ? "beta" : "release"
762+
changelog = project.changelog.replace("{version}", modVersion)
763+
uploadFile = jar
764+
gameVersions = [project.minecraft.version]
765+
loaders = ["forge"]
766+
}
767+
if (modrinthDependencies.size() != 0) {
768+
String[] deps = modrinthDependencies.split(";")
769+
deps.each { dep ->
770+
if (dep.size() == 0) {
771+
return
772+
}
773+
String[] parts = dep.split(":")
774+
String[] qual = parts[0].split("-")
775+
String scope = qual[0]
776+
String type = qual[1]
777+
String name = parts[1]
778+
addModrinthDep(scope, type, name)
779+
}
780+
}
781+
tasks.modrinth.dependsOn(build)
782+
tasks.publish.dependsOn(modrinth)
783+
}
784+
785+
def addModrinthDep(scope, type, name) {
786+
com.modrinth.minotaur.dependencies.Dependency dep;
787+
if (!(scope in ["required", "optional", "incompatible", "embedded"])) {
788+
throw new Exception("Invalid modrinth dependency scope: " + scope)
789+
}
790+
switch (type) {
791+
case "project":
792+
dep = new ModDependency(name, scope)
793+
break
794+
case "version":
795+
dep = new VersionDependency(name, scope)
796+
break
797+
default:
798+
throw new Exception("Invalid modrinth dependency type: " + type)
799+
}
800+
project.modrinth.dependencies.add(dep)
801+
}
802+
803+
def addCurseForgeRelation(type, name) {
804+
if (!(type in ["requiredDependency", "embeddedLibrary", "optionalDependency", "tool", "incompatible"])) {
805+
throw new Exception("Invalid CurseForge relation type: " + type)
806+
}
807+
CurseArtifact artifact = project.curseforge.curseProjects[0].mainArtifact
808+
CurseRelation rel = (artifact.curseRelations ?: (artifact.curseRelations = new CurseRelation()))
809+
rel."$type"(name)
810+
}
811+
707812
// Updating
708813
task updateBuildScript {
709814
doLast {
@@ -995,11 +1100,11 @@ def checkPropertyExists(String propertyName) {
9951100
}
9961101

9971102
def propertyDefaultIfUnset(String propertyName, defaultValue) {
998-
if (!project.hasProperty(propertyName)) {
1103+
if (!project.hasProperty(propertyName) || project.property(propertyName) == "") {
9991104
project.ext.setProperty(propertyName, defaultValue)
10001105
}
10011106
}
10021107

10031108
def getFile(String relativePath) {
10041109
return new File(projectDir, relativePath)
1005-
}
1110+
}

gradle.properties

Lines changed: 116 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,120 @@
1+
# Mod settings
2+
#region mod
3+
14
modName = FalsePatternLib
25

36
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
47
modId = falsepatternlib
58

9+
# The "root package" of your mod. All of your mod classes *should* be placed under this package for simplicity.
610
modGroup = com.falsepattern.lib
711

12+
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
13+
# leave this property empty.
14+
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
15+
apiPackage =
16+
817
# WHY is there no version field?
918
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
1019
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
20+
# However, if you really want to, you can use the VERSION environment variable to override this.
21+
22+
minecraftVersion = 1.7.10
23+
forgeVersion = 10.13.4.1614
24+
25+
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
26+
# restart Minecraft in development. Choose this dependent on your mod:
27+
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
28+
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
29+
developmentEnvironmentUserName = Developer
30+
31+
#endregion mod
1132

12-
#
1333
# Publishing settings
14-
#
34+
#region publishing
1535

16-
# The server to upload the artifacts to
36+
# Note: Both the modrinth and the curseforge publications are invoked by the "publish" gradle task
37+
# (when the respective publication's project ID is set up correctly, of course). You don't need to individually run
38+
# each of them.
39+
40+
# Maven publishing
41+
#region maven
42+
43+
# The maven server to upload the artifacts to
1744
repositoryURL = https://mvn.falsepattern.com/releases
1845

1946
# What name is the login information inside ~/.m2/settings.xml stored under
2047
# (see https://gist.github.com/FalsePattern/82d93e3cfab01f671cc5f4a95931cfe3 for an example)
21-
repositoryName = mvnpattern
48+
# You can also use the MAVEN_DEPLOY_USER and MAVEN_DEPLOY_PASSWORD environment variables to set this information!
49+
repositoryName = mavenpatternasdfasdf
2250

23-
# What the artifact should be called. These will be the "name" of the published package, suffixed with the minecraft version with a -mc prefix (groupid:artifactid-mcminecraftVersion:version:qualifier).
51+
# What the artifact should be called. These will be the "name" of the published package, suffixed with the minecraft
52+
# version with a -mc prefix (groupid:artifactid-mcminecraftVersion:version:qualifier).
2453
# For instance, the default values this example ships with would turn into com.myname:mymodid-mc1.7.10:version
2554
# The version is determined automatically from the git version.
2655
mavenGroupId = com.falsepattern
2756
mavenArtifactId = falsepatternlib
2857

58+
#endregion maven
59+
60+
# Modrinth publishing
61+
#region modrinth
62+
63+
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
64+
65+
# The project's ID on Modrinth. Can be either the slug or the ID.
66+
# Leave this empty if you don't want to publish on Modrinth.
67+
modrinthProjectId = eGLBEILf
68+
69+
# The project's dependencies on Modrinth. You can use this to refer to other projects on Modrinth.
70+
# Syntax: scope1-type1:name1;scope2-type2:name2;...
71+
# Where scope can be one of [required, optional, incompatible, embedded],
72+
# type can be one of [project, version],
73+
# and the name is the Modrinth project or version slug/id of the other mod.
74+
# Example: required-project:fplib;optional-project:spongemixin1710;incompatible-project:gregtech
75+
modrinthDependencies =
76+
77+
#endregion modrinth
78+
79+
# CurseForge publishing
80+
#region curseforge
81+
82+
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
83+
84+
# The project's numeric ID on CurseForge. You can find this in the About Project box.
85+
# Leave this empty if you don't want to publish on CurseForge.
86+
curseForgeProjectId = 665627
87+
88+
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
89+
# Syntax: type1:name1;type2:name2;...
90+
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
91+
# and the name is the CurseForge project id of the other mod.
92+
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
93+
curseForgeRelations =
94+
95+
#endregion curseforge
96+
97+
# This will be inserted as the changelog text in the Modrinth/CurseForge publications.
98+
# If the text contains "{version}", it will be replaced with the current mod version. This is useful when the changelog
99+
# is just a URL pointing to a GitHub release tag.
100+
# If left empty, the changelog text will be set to "No changelog URL was provided."
101+
# Example: https://github.com/myname/mymod/releases/tag/{version}
102+
changelog = https://github.com/FalsePattern/FalsePatternLib/releases/tag/{version}
103+
104+
# endregion publishing
105+
106+
# Buildscript automatic update checker settings
107+
#region autoupdates
108+
29109
# Will update your build.gradle automatically whenever an update is available
30110
autoUpdateBuildScript = false
31111
# Disable checking of buildscript updates.
32112
skipBuildScriptUpdateCheck = false
33113

34-
minecraftVersion = 1.7.10
35-
forgeVersion = 10.13.4.1614
114+
#endregion autoupdates
36115

37-
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
38-
# restart Minecraft in development. Choose this dependent on your mod:
39-
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
40-
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
41-
developmentEnvironmentUserName = Developer
116+
# Gradle token strings
117+
#region gradletokens
42118

43119
# Define a source file of your project with:
44120
# public static final String VERSION = "GRADLETOKEN_VERSION";
@@ -51,14 +127,10 @@ gradleTokenModName = GRADLETOKEN_MODNAME
51127
gradleTokenVersion = GRADLETOKEN_VERSION
52128
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
53129

54-
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
55-
# leave this property empty.
56-
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
57-
apiPackage =
130+
#endregion gradletokens
58131

59-
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
60-
# Example value: mymodid_at.cfg
61-
accessTransformersFile =
132+
# Mixins
133+
#region mixins
62134

63135
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
64136
usesMixins = false
@@ -68,22 +140,39 @@ hasMixinDeps = false
68140
mixinPlugin =
69141
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
70142
mixinsPackage =
71-
# Specify a preinit mixin here. Preinit mixins should be used very rarely, if at all, so this mixin config will not be managed by the buildscript, only included.
143+
# Specify a preinit mixin here. Preinit mixins should be used very rarely, if at all, so this mixin config will not be
144+
# managed by the buildscript, only included.
72145
mixinPreinitConfig =
73-
# By default, the buildscript uses mixin-booter-legacy for mixins. You can force the buildscript to use the obsolete SpongeMixins
74-
# library using this setting.
146+
# By default, the buildscript uses mixin-booter-legacy for mixins. You can force the buildscript to use the obsolete
147+
# SpongeMixins library using this setting.
75148
# MixinBooterLegacy provides Mixins 0.8.2
76149
# SpongeMixins provides Mixins 0.7.11 on the official version, and Mixins 0.7.12 on the nh version
77150
useObsoleteSpongeMixins = false
151+
152+
#endregion mixins
153+
154+
# Coremod and access transformers
155+
#region core
156+
157+
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
158+
# Example value: mymodid_at.cfg
159+
accessTransformersFile =
160+
78161
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
79-
# This parameter is for legacy compatability only
162+
# This parameter is for legacy compatibility only
80163
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
81164
coreModClass = internal.asm.CoreLoadingPlugin
165+
166+
#endregion core
167+
168+
# Miscellaneous settings
169+
#region misc
170+
82171
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
83172
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
84173
containsMixinsAndOrCoreModOnly = false
85174

86-
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
175+
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
87176
# responsibility check the licence and request permission for distribution, if required.
88177
usesShadowedDependencies = false
89178

@@ -96,3 +185,6 @@ remapStubs = true
96185
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
97186
# projects. New projects should not use this parameter.
98187
#customArchiveBaseName =
188+
189+
#endregion misc
190+

0 commit comments

Comments
 (0)