Skip to content

Commit

Permalink
Migrate to mod-publish-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jan 18, 2025
1 parent 4eb0f5b commit 4844b94
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
check-latest: true
- name: Build and Publish
env:
CURSEFORGE_API_KEY: ${{ secrets.CREEPER_CF }}
CURSEFORGE_TOKEN: ${{ secrets.CREEPER_CF }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew curseforge modrinth
run: ./gradlew publishMods
90 changes: 34 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ plugins {
id "java"
id "maven-publish"
id "org.ajoberstar.grgit" version "5.3.0"
id "com.matthewprenger.cursegradle" version "1.4.0" // This repository is archived on GH
id "com.modrinth.minotaur" version "2.8.7"
id "fabric-loom" version "1.9-SNAPSHOT" apply false
id "com.github.ben-manes.versions" version "0.51.0"
id "xyz.wagyourtail.jvmdowngrader" version "1.0.1"
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
}

def ENV = System.getenv()
Expand Down Expand Up @@ -186,63 +185,42 @@ processResources {
List<String> mcReleases = Arrays.stream(rootProject.publish_mc_versions.toString().split(","))
.map({ it -> it.trim() })
.collect(Collectors.toList())
List<String> javaVersions = IntStream.rangeClosed(8, 22)
.mapToObj { n -> (String) "Java $n" }
.collect(Collectors.toList())
String changelogMsg = "A changelog can be found at https://github.com/ViaVersion/ViaFabric/commits"
String versionNameMsg = "[${getBranch()}] ViaFabric " + rootProject.version

curseforge {
if (ENV.CURSEFORGE_API_KEY) {
apiKey = ENV.CURSEFORGE_API_KEY
}

project {
id = "391298"
changelog = changelogMsg
releaseType = "beta" // alpha is hidden by default

mcReleases.forEach { ver -> addGameVersion(ver) }
if (!rootProject.curseforge_mc_snapshot.isEmpty()) addGameVersion(rootProject.curseforge_mc_snapshot)
javaVersions.forEach(v -> addGameVersion(v))
addGameVersion("Fabric")

mainArtifact(remapJar) {
displayName = versionNameMsg
relations {
optionalDependency("fabric-api")
embeddedLibrary("cotton-client-commands")
}
publishMods {
file = remapJar.archiveFile
changelog = "A changelog can be found at https://github.com/ViaVersion/ViaFabric/commits"
version = rootProject.version
displayName = "[${getBranch()}] ViaFabric " + rootProject.version
modLoaders.add("fabric")
dryRun = providers.environmentVariable("CURSEFORGE_TOKEN").getOrNull() == null

curseforge {
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
projectId = "391298"
type = BETA // alpha is hidden by default

javaVersions.add(JavaVersion.VERSION_1_8)
javaVersions.add(JavaVersion.VERSION_1_9)
javaVersions.add(JavaVersion.VERSION_1_10)
IntStream.rangeClosed(11, 22).forEach { n -> javaVersions.add(JavaVersion.valueOf("VERSION_" + n)) }

minecraftVersions.addAll(mcReleases)
if (!rootProject.curseforge_mc_snapshot.isEmpty()) {
minecraftVersions.add(rootProject.curseforge_mc_snapshot)
}

afterEvaluate {
uploadTask.dependsOn("remapJar")
optional("fabric-api")
embeds("cotton-client-commands")
}
modrinth {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "YlKdE5VK"
type = ALPHA
minecraftVersions.addAll(mcReleases)
if (!rootProject.modrinth_mc_snapshot.isEmpty()) {
minecraftVersions.add(rootProject.modrinth_mc_snapshot.toString())
}
}

options {
forgeGradleIntegration = false
}
}

modrinth {
token.set(ENV.MODRINTH_TOKEN)
projectId.set("YlKdE5VK")
versionType.set("alpha")
versionNumber.set(rootProject.version)
versionName.set(versionNameMsg)
changelog.set(changelogMsg)

uploadFile.set(remapJar)

List<String> mcs = new ArrayList<>(mcReleases)
if (!rootProject.modrinth_mc_snapshot.isEmpty()) mcs.add(rootProject.modrinth_mc_snapshot.toString())
gameVersions.set(mcs)
loaders.set(["fabric"])

dependencies {
optional.project "P7dR8mSH" // fabric api
embedded.project "P1OZGk5p" // viaversion
optional("fabric-api")
embeds("viaversion")
}
}

Expand Down

0 comments on commit 4844b94

Please sign in to comment.