Skip to content

Commit

Permalink
publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMCLoveMan committed Feb 27, 2024
1 parent 943b102 commit 45c7a38
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '6.+'
id 'me.shedaniel.unified-publishing' version '0.1.+'
}

group = 'net.themcbrothers'
Expand Down Expand Up @@ -165,6 +166,96 @@ artifacts {

jar.finalizedBy('reobfJar')

publishing {
publications { PublicationContainer publicationContainer ->
publicationContainer.register('mavenJava', MavenPublication) { MavenPublication publication ->
from components.java
publication.artifactId = archive_base
publication.version = "$minecraft_version-$mod_version"
}
}
repositories {
maven {
credentials {
username = System.getenv('PUBLISH_USER')
password = System.getenv('PUBLISH_PASSWORD')
}

url 'https://nexus.themcbrothers.net/repository/maven-releases/'
}
}
}

private String getChangelogText(boolean hasTitle) {
File changelogFile = file('changelog.txt')
String str = ''
int lineCount = 0
boolean done = false
changelogFile.eachLine {
if (done || it == null) {
return
}
if (it.length() > 1) {
String temp = it
if (lineCount == 0) {
temp = hasTitle ? "## $mod_name $mod_version" : ''
} else if (it.startsWith('-')) {
temp = temp.replaceAll("(\\S+/\\S+)#(\\d+)\\b", "[\$0](https://github.com/\$1/issues/\$2)")
temp = temp.replaceAll("#(\\d+)\\b(?!</a>)", "[\$0](https://github.com/$github_repo/issues/\$1)")
} else {
temp = "#### $temp"
}
str += "$temp\n"
lineCount++
return
} else {
done = true
}
return
}
return str
}

unifiedPublishing {
project {
version = "$minecraft_version-$mod_version"
displayName = "[$minecraft_version] v$mod_version"
releaseType = project.artifact_type
gameVersions = [minecraft_version]
gameLoaders = ["forge"]

mainPublication tasks.jar

var curseforgeToken = System.getenv('CURSEFORGE_TOKEN')
var modrinthToken = System.getenv('MODRINTH_TOKEN')

if (curseforgeToken != null) {
curseforge {
token = curseforgeToken
id = project.curse_project
changelog = getChangelogText(true)
gameVersions.addAll "Java 17"

relations {
optional "jei"
}
}
}

if (modrinthToken != null) {
modrinth {
token = modrinthToken
id = project.modrinth_project
changelog = getChangelogText(false)

relations {
optional "jei"
}
}
}
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}

0 comments on commit 45c7a38

Please sign in to comment.