diff --git a/.github/workflows/buildrelease.yml b/.github/workflows/buildrelease.yml index f9ff4c9cd1..434688ca55 100644 --- a/.github/workflows/buildrelease.yml +++ b/.github/workflows/buildrelease.yml @@ -71,11 +71,13 @@ jobs: } >> $GITHUB_OUTPUT - name: Publish using mod-publish-plugin - run: ./gradlew build publishMods + run: ./gradlew build publishMods publish env: + BUILD_SOURCES_JAR: true CHANGELOG: ${{ steps.read_changelog.outputs.changelog }} CHANGELOG_HIGHLIGHT: ${{ steps.read_changelog.outputs.changelog_highlight }} REF_NAME: ${{ github.ref_name }} + GITHUB_ACTOR: ${{ github.actor }} GITHUB_TOKEN: ${{ secrets.GH_RELEASE }} DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} diff --git a/build.gradle b/build.gradle index 1a8dccf996..d355d064bf 100644 --- a/build.gradle +++ b/build.gradle @@ -197,7 +197,7 @@ dependencies { // Legacy Item DFU include implementation("net.azureaaron:legacy-item-dfu:${project.legacy_item_dfu_version}") - // JGit used pull data from the NEU item repo + // JGit used to pull data from the NEU item repo include implementation("org.eclipse.jgit:org.eclipse.jgit:${project.jgit_version}") // Apache Commons Math @@ -244,6 +244,10 @@ tasks.withType(JavaCompile).configureEach { } java { + if (System.getenv("BUILD_SOURCES_JAR")?.toBoolean()) { + withSourcesJar() + } + sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 } @@ -296,14 +300,14 @@ spotless { /^( "skyblocker(?:\.([^."]++)(?:\.[^"]++)?)?": "(?:[^\\"]++|\\.)*+",)$\n^(?= "skyblocker\.(?!\2[."]))/, '$1\n\n' replaceRegex \ - "Separate different thrid stems if the first two stems are skyblocker.config", + "Separate different third stems if the first two stems are skyblocker.config", // The third and remaining stems are optional, allowing matching lines with only two stems (in this case "skyblocker.config"), and separating it from other keys that start with "skyblocker.config.[whatever]". /^( "skyblocker\.config(?:\.([^."]++)(?:\.[^"]++)?)?": "(?:[^\\"]++|\\.)*+",)$\n^(?= "skyblocker\.config\.(?!\2[."]))/, '$1\n\n' final List excludeCategories = ["debug", "eventNotifications", "quickNav", "shortcutToKeybindsSettings", "title"] final String excludeCategoriesLookahead = /(?!(?:${excludeCategories.join('|')})(?=[."]))/ replaceRegex \ - "Separate different fouth stems if the first three stems are skyblocker.config.[configCategory]", + "Separate different fourth stems if the first three stems are skyblocker.config.[configCategory]", // A negative lookahead is used before the third stem to exclude the above list of third stems. // The fourth and remaining stems are optional, allowing matching lines with only three stems (such as "skyblocker.config.[configCategory]"), and separating them from other keys that start with "skyblocker.config.[configCategory].[whatever]". // This treats keys with only three stems as if they have an empty fourth stem, which is considered different from any other fourth stem, therefore inserting a newline after them. @@ -345,6 +349,9 @@ def truncateChangelog = { String text, int limit -> publishMods { file = remapJar.archiveFile + if (System.getenv("BUILD_SOURCES_JAR")?.toBoolean()) { + additionalFiles.from(remapSourcesJar.archiveFile) + } changelog = System.getenv('CHANGELOG_HIGHLIGHT') version = "v${project.version}" displayName = "Skyblocker ${mod_version} for ${minecraft_version}" @@ -395,16 +402,22 @@ publishMods { // configure the maven publication publishing { publications { - mavenJava(MavenPublication) { + create("mavenJava", MavenPublication) { + groupId = "de.hysky" + artifactId = base.archivesName from components.java } } // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. + maven { + name = "GitHubPackages" + url = "https://maven.pkg.github.com/SkyblockerMod/Skyblocker" + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } } }