diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml index 4ffdc90..2602312 100644 --- a/.github/workflows/release-tags.yml +++ b/.github/workflows/release-tags.yml @@ -11,9 +11,6 @@ on: jobs: build: runs-on: ubuntu-latest - env: - MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }} - MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }} steps: - uses: actions/checkout@v2 with: @@ -47,5 +44,10 @@ jobs: title: "${{ env.RELEASE_VERSION }}" files: build/libs/*.jar - - name: Publish to maven - run: ./gradlew publish \ No newline at end of file + - name: Publish to Maven, Modrinth, and CurseForge + run: ./gradlew publish + env: + MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }} + MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} diff --git a/build.gradle b/build.gradle index 8dd8229..78daf79 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1656003793falsepattern36 +//version: 1656003793falsepattern38 /* DO NOT CHANGE THIS FILE! @@ -9,6 +9,10 @@ Please check https://github.com/FalsePattern/ExampleMod1.7.10/blob/main/build.gr import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import com.matthewprenger.cursegradle.CurseArtifact +import com.matthewprenger.cursegradle.CurseRelation +import com.modrinth.minotaur.dependencies.ModDependency +import com.modrinth.minotaur.dependencies.VersionDependency import org.gradle.internal.logging.text.StyledTextOutput.Style import org.gradle.internal.logging.text.StyledTextOutputFactory @@ -63,6 +67,8 @@ plugins { id 'com.palantir.git-version' version '0.13.0' id 'de.undercouch.download' version '5.0.1' id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false + id 'com.modrinth.minotaur' version '2.+' apply false + id 'com.matthewprenger.cursegradle' version '1.4.0' apply false } apply plugin: 'com.falsepattern.jtweaker' @@ -122,6 +128,12 @@ propertyDefaultIfUnset("mixinPreinitConfig", "") propertyDefaultIfUnset("remapStubs", false) propertyDefaultIfUnset("useObsoleteSpongeMixins", false) +propertyDefaultIfUnset("modrinthProjectId", "") +propertyDefaultIfUnset("modrinthDependencies", "") +propertyDefaultIfUnset("curseForgeProjectId", "") +propertyDefaultIfUnset("curseForgeRelations", "") +propertyDefaultIfUnset("changelog", "No changelog URL was provided.") + propertyDefaultIfUnset("remoteMappings", "https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/") propertyDefaultIfUnset("mappingsChannel", "stable") propertyDefaultIfUnset("mappingsVersion", "12") @@ -704,6 +716,99 @@ publishing { } } + +if (curseForgeProjectId != "") { + apply plugin: 'com.matthewprenger.cursegradle' + curseforge { + apiKey = System.getenv("CURSEFORGE_TOKEN") ?: "" + project { + id = curseForgeProjectId + changelogType = "text" + changelog = project.changelog.replace("{version}", modVersion) + releaseType = modVersion.contains("-a") ? "alpha" : modVersion.contains("-b") ? "beta" : "release" + addGameVersion project.minecraft.version + mainArtifact(jar) { + displayName = "$modName version: $modVersion" + } + } + options { + javaIntegration = false + forgeGradleIntegration = false + } + } + if (curseForgeRelations.size() != 0) { + String[] deps = curseForgeRelations.split(";") + deps.each { dep -> + if (dep.size() == 0) { + return + } + String[] parts = dep.split(":") + String type = parts[0] + String name = parts[1] + addCurseForgeRelation(type, name) + } + } + tasks.curseforge.dependsOn(build) + tasks.publish.dependsOn(curseforge) +} + +if (modrinthProjectId != "") { + apply plugin: 'com.modrinth.minotaur' + modrinth { + token = System.getenv("MODRINTH_TOKEN") + projectId = modrinthProjectId + versionNumber = modVersion + versionType = modVersion.contains("-a") ? "alpha" : modVersion.contains("-b") ? "beta" : "release" + changelog = project.changelog.replace("{version}", modVersion) + uploadFile = jar + gameVersions = [project.minecraft.version] + loaders = ["forge"] + } + if (modrinthDependencies.size() != 0) { + String[] deps = modrinthDependencies.split(";") + deps.each { dep -> + if (dep.size() == 0) { + return + } + String[] parts = dep.split(":") + String[] qual = parts[0].split("-") + String scope = qual[0] + String type = qual[1] + String name = parts[1] + addModrinthDep(scope, type, name) + } + } + tasks.modrinth.dependsOn(build) + tasks.publish.dependsOn(modrinth) +} + +def addModrinthDep(scope, type, name) { + com.modrinth.minotaur.dependencies.Dependency dep; + if (!(scope in ["required", "optional", "incompatible", "embedded"])) { + throw new Exception("Invalid modrinth dependency scope: " + scope) + } + switch (type) { + case "project": + dep = new ModDependency(name, scope) + break + case "version": + dep = new VersionDependency(name, scope) + break + default: + throw new Exception("Invalid modrinth dependency type: " + type) + } + project.modrinth.dependencies.add(dep) +} + +def addCurseForgeRelation(type, name) { + if (!(type in ["requiredDependency", "embeddedLibrary", "optionalDependency", "tool", "incompatible"])) { + throw new Exception("Invalid CurseForge relation type: " + type) + } + CurseArtifact artifact = project.curseforge.curseProjects[0].mainArtifact + CurseRelation rel = (artifact.curseRelations ?: (artifact.curseRelations = new CurseRelation())) + rel."$type"(name) +} + // Updating task updateBuildScript { doLast { @@ -995,11 +1100,11 @@ def checkPropertyExists(String propertyName) { } def propertyDefaultIfUnset(String propertyName, defaultValue) { - if (!project.hasProperty(propertyName)) { + if (!project.hasProperty(propertyName) || project.property(propertyName) == "") { project.ext.setProperty(propertyName, defaultValue) } } def getFile(String relativePath) { return new File(projectDir, relativePath) -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d10ba74..91c5d31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,44 +1,120 @@ +# Mod settings +#region mod + modName = FalsePatternLib # This is a case-sensitive string to identify your mod. Convention is to use lower case. modId = falsepatternlib +# The "root package" of your mod. All of your mod classes *should* be placed under this package for simplicity. modGroup = com.falsepattern.lib +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can +# leave this property empty. +# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api +apiPackage = + # WHY is there no version field? # The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the # code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/ +# However, if you really want to, you can use the VERSION environment variable to override this. + +minecraftVersion = 1.7.10 +forgeVersion = 10.13.4.1614 + +# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you +# restart Minecraft in development. Choose this dependent on your mod: +# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name +# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty +developmentEnvironmentUserName = Developer + +#endregion mod -# # Publishing settings -# +#region publishing -# The server to upload the artifacts to +# Note: Both the modrinth and the curseforge publications are invoked by the "publish" gradle task +# (when the respective publication's project ID is set up correctly, of course). You don't need to individually run +# each of them. + +# Maven publishing +#region maven + +# The maven server to upload the artifacts to repositoryURL = https://mvn.falsepattern.com/releases # What name is the login information inside ~/.m2/settings.xml stored under # (see https://gist.github.com/FalsePattern/82d93e3cfab01f671cc5f4a95931cfe3 for an example) -repositoryName = mvnpattern +# You can also use the MAVEN_DEPLOY_USER and MAVEN_DEPLOY_PASSWORD environment variables to set this information! +repositoryName = mavenpatternasdfasdf -# 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). +# 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). # For instance, the default values this example ships with would turn into com.myname:mymodid-mc1.7.10:version # The version is determined automatically from the git version. mavenGroupId = com.falsepattern mavenArtifactId = falsepatternlib +#endregion maven + +# Modrinth publishing +#region modrinth + +# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token. + +# The project's ID on Modrinth. Can be either the slug or the ID. +# Leave this empty if you don't want to publish on Modrinth. +modrinthProjectId = eGLBEILf + +# The project's dependencies on Modrinth. You can use this to refer to other projects on Modrinth. +# Syntax: scope1-type1:name1;scope2-type2:name2;... +# Where scope can be one of [required, optional, incompatible, embedded], +# type can be one of [project, version], +# and the name is the Modrinth project or version slug/id of the other mod. +# Example: required-project:fplib;optional-project:spongemixin1710;incompatible-project:gregtech +modrinthDependencies = + +#endregion modrinth + +# CurseForge publishing +#region curseforge + +# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens. + +# The project's numeric ID on CurseForge. You can find this in the About Project box. +# Leave this empty if you don't want to publish on CurseForge. +curseForgeProjectId = 665627 + +# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge. +# Syntax: type1:name1;type2:name2;... +# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible], +# and the name is the CurseForge project id of the other mod. +# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft +curseForgeRelations = + +#endregion curseforge + +# This will be inserted as the changelog text in the Modrinth/CurseForge publications. +# If the text contains "{version}", it will be replaced with the current mod version. This is useful when the changelog +# is just a URL pointing to a GitHub release tag. +# If left empty, the changelog text will be set to "No changelog URL was provided." +# Example: https://github.com/myname/mymod/releases/tag/{version} +changelog = https://github.com/FalsePattern/FalsePatternLib/releases/tag/{version} + +# endregion publishing + +# Buildscript automatic update checker settings +#region autoupdates + # Will update your build.gradle automatically whenever an update is available autoUpdateBuildScript = false # Disable checking of buildscript updates. skipBuildScriptUpdateCheck = false -minecraftVersion = 1.7.10 -forgeVersion = 10.13.4.1614 +#endregion autoupdates -# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you -# restart Minecraft in development. Choose this dependent on your mod: -# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name -# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty -developmentEnvironmentUserName = Developer +# Gradle token strings +#region gradletokens # Define a source file of your project with: # public static final String VERSION = "GRADLETOKEN_VERSION"; @@ -51,14 +127,10 @@ gradleTokenModName = GRADLETOKEN_MODNAME gradleTokenVersion = GRADLETOKEN_VERSION gradleTokenGroupName = GRADLETOKEN_GROUPNAME -# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can -# leave this property empty. -# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api -apiPackage = +#endregion gradletokens -# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ -# Example value: mymodid_at.cfg -accessTransformersFile = +# Mixins +#region mixins # Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! usesMixins = false @@ -68,22 +140,39 @@ hasMixinDeps = false mixinPlugin = # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! mixinsPackage = -# 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. +# 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. mixinPreinitConfig = -# By default, the buildscript uses mixin-booter-legacy for mixins. You can force the buildscript to use the obsolete SpongeMixins -# library using this setting. +# By default, the buildscript uses mixin-booter-legacy for mixins. You can force the buildscript to use the obsolete +# SpongeMixins library using this setting. # MixinBooterLegacy provides Mixins 0.8.2 # SpongeMixins provides Mixins 0.7.11 on the official version, and Mixins 0.7.12 on the nh version useObsoleteSpongeMixins = false + +#endregion mixins + +# Coremod and access transformers +#region core + +# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ +# Example value: mymodid_at.cfg +accessTransformersFile = + # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! -# This parameter is for legacy compatability only +# This parameter is for legacy compatibility only # Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin coreModClass = internal.asm.CoreLoadingPlugin + +#endregion core + +# Miscellaneous settings +#region misc + # If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class # that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! containsMixinsAndOrCoreModOnly = false -# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your +# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your # responsibility check the licence and request permission for distribution, if required. usesShadowedDependencies = false @@ -96,3 +185,6 @@ remapStubs = true # Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older # projects. New projects should not use this parameter. #customArchiveBaseName = + +#endregion misc +