- Create an env in your GitHub settings. Call it
gradle
. - Add a variable to the env named
RELEASE_TYPE
, and give it a value ofalpha
,beta
, orrelease
. - Add a secret to the env named
MODRINTH_TOKEN
, and give it the value of your Modrinth Token. - Paste
publishing.yml
in.github/workflows/publishing.yml
- Add the following to your
build.gradle.kts
:
plugins {
`maven-publish`
// also add the minotaur plugin. See modrinth docs.
}
modrinth { // for more info see modrinth docs
token.set(System.getenv("MODRINTH_TOKEN"))
versionType.set(System.getenv("MODRINTH_TYPE"))
uploadFile.set(tasks.remapJar)
syncBodyFrom.set(rootProject.file("README.md").readText())
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/USERNAME/REPOSITORY") // <- replace these
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
register<MavenPublication>("MOD_NAME") { <- replace this
from(components["java"])
groupId = "io.github.USERNAME" <- and this
artifactId = "MOD_ID" <- and this
}
}
}
- That's it! you're done!
If you want to create a version, just use this handy tool!
GitHub provides you the version in maven format. Example. All you need to do is to convert it to Gradle:
repositories {
maven {
name = "GitHub Packages"
url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY")
}
}
dependencies {
modImplementation("${groupId}:${artifactId}:${version}")
}
repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
}
dependencies {
modImplementation "maven.modrinth:MOD_ID:mcMC_VERSION-MOD_VERSION"
}