Skip to content

Commit

Permalink
Add modrinth and github publishing to buildscript
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Dec 3, 2023
1 parent 8c968f8 commit 87e0afd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ bin/

run/
logs/

/changelog.txt
27 changes: 25 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.+'
id 'com.github.breadmoirai.github-release' version '2.4.1'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -86,16 +87,38 @@ jar {
from "LICENSE"
}

// read the changelog from the changelog.txt file, make sure the changelog is recent to avoid accidentally using the previous version's changelog.
def changelogFile = file('changelog.txt')
def changelogText = changelogFile.exists() && System.currentTimeMillis() - changelogFile.lastModified() <= 1000 * 60 * 60 ?
changelogFile.readLines('UTF-8').join('\n') : ''

modrinth {
token = project.hasProperty('modrinthKey') ? project.modrinthKey : System.getenv("MODRINTH_TOKEN")
projectId = 'clientcommands' // This can be the project ID or the slug. Either will work!
uploadFile = remapJar
gameVersions = project.minecraft_version_list.split('\\s*,\\s*').toList()
loaders = ['fabric', 'quilt']
gameVersions.set(project.minecraft_version_list.split('\\s*,\\s*').toList())
loaders.set(['fabric', 'quilt'])
changelog = changelogText
dependencies {
required.project 'fabric-api'
}
}
tasks.modrinth.onlyIf {
!changelogText.isBlank()
}

githubRelease {
token(project.hasProperty('githubKey') ? project.githubKey : System.getenv("GITHUB_TOKEN"))
owner 'Earthcomputer'
repo "clientcommands"
targetCommitish 'fabric'
releaseName "Version ${project.version} for Minecraft ${project.minecraft_version_list_presentable}"
body changelogText
releaseAssets remapJar.outputs
}
tasks.githubRelease.onlyIf {
!changelogText.isBlank()
}

publishing {
publications {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ org.gradle.jvmargs=-Xmx2G
minecraft_version=1.20.2
minecraft_version_dependency=1.20.2
minecraft_version_list=1.20.2
minecraft_version_list_presentable=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.15.0

Expand Down

0 comments on commit 87e0afd

Please sign in to comment.