From 47439f8ccc82f6d48ba7990cb3e0ee3017d71b2c Mon Sep 17 00:00:00 2001 From: glowredman <35727266+glowredman@users.noreply.github.com> Date: Thu, 29 Jun 2023 18:29:00 +0200 Subject: [PATCH] Try again 2 --- .github/workflows/release-tags.yml | 10 ++---- build.gradle | 58 +++++++++++++++--------------- gradle.properties | 6 ++++ 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml index 6446a51..13bb0e6 100644 --- a/.github/workflows/release-tags.yml +++ b/.github/workflows/release-tags.yml @@ -77,18 +77,12 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to Maven + - name: Publish to Maven, Modrinth and CurseForge run: ./gradlew --build-cache --info --stacktrace build publish continue-on-error: true env: MAVEN_USER: ${{ secrets.MAVEN_USER }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - if: ${{ env.MAVEN_USER != '' }} - - - name: Publish to Modrinth and/or CurseForge - run: ./gradlew --build-cache --info --stacktrace publishMNCF - continue-on-error: true - env: MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} - if: ${{ env.MODRINTH_TOKEN != '' || env.CURSEFORGE_TOKEN != '' }} + if: ${{ env.MAVEN_USER != '' || env.MODRINTH_TOKEN != '' || env.CURSEFORGE_TOKEN }} diff --git a/build.gradle b/build.gradle index cc6a416..93c98ae 100644 --- a/build.gradle +++ b/build.gradle @@ -115,6 +115,7 @@ propertyDefaultIfUnset("usesMixinDebug", project.usesMixins) propertyDefaultIfUnset("forceEnableMixins", false) propertyDefaultIfUnset("channel", "stable") propertyDefaultIfUnset("mappingsVersion", "12") +propertyDefaultIfUnset("mavenURL", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases") propertyDefaultIfUnset("modrinthProjectId", "") propertyDefaultIfUnset("modrinthRelations", "") propertyDefaultIfUnset("curseForgeProjectId", "") @@ -1101,40 +1102,37 @@ tasks.named("processIdeaSettings").configure { // workaround variable hiding in pom processing def projectConfigs = project.configurations -publishing { - publications { - create("maven", MavenPublication) { - from components.java +if (System.getenv("MAVEN_USER") != null && System.getenv("MAVEN_PASSWORD") != null) { + publishing { + publications { + create("maven", MavenPublication) { + from components.java - if (apiPackage) { - artifact apiJar - } + if (apiPackage) { + artifact apiJar + } - groupId = System.getenv("ARTIFACT_GROUP_ID") ?: project.group - artifactId = System.getenv("ARTIFACT_ID") ?: project.name - // Using the identified version, not project.version as it has the prepended 1.7.10 - version = System.getenv("RELEASE_VERSION") ?: identifiedVersion + groupId = System.getenv("ARTIFACT_GROUP_ID") ?: project.group + artifactId = System.getenv("ARTIFACT_ID") ?: project.name + // Using the identified version, not project.version as it has the prepended 1.7.10 + version = System.getenv("RELEASE_VERSION") ?: identifiedVersion + } } - } - repositories { - maven { - url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases" - allowInsecureProtocol = true - credentials { - username = System.getenv("MAVEN_USER") ?: "NONE" - password = System.getenv("MAVEN_PASSWORD") ?: "NONE" + repositories { + maven { + url = mavenURL + allowInsecureProtocol = mavenURL.startsWith("http://") + credentials { + username = System.getenv("MAVEN_USER") + password = System.getenv("MAVEN_PASSWORD") + } } } } } -tasks.register('publishMNCF') { - group = 'publishing' - description = 'Publish to Modrinth and/or CurseForge' -} - -if (modrinthProjectId.size() != 0) { +if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) { apply plugin: 'com.modrinth.minotaur' File changelogFile = new File(System.getenv("CHANGELOG_FILE") ?: "CHANGELOG.md") @@ -1149,7 +1147,7 @@ if (modrinthProjectId.size() != 0) { additionalFiles = getSecondaryArtifacts() gameVersions = [minecraftVersion] loaders = ["forge"] - debugMode = true + debugMode = false } if (modrinthRelations.size() != 0) { @@ -1167,10 +1165,10 @@ if (modrinthProjectId.size() != 0) { addModrinthDep("required", "project", "unimixins") } tasks.modrinth.dependsOn(build) - tasks.publishMNCF.dependsOn(tasks.modrinth) + tasks.publish.dependsOn(tasks.modrinth) } -if (curseForgeProjectId.size() != 0) { +if (curseForgeProjectId.size() != 0 && System.getenv("CURSEFORGE_TOKEN") != null) { apply plugin: 'com.matthewprenger.cursegradle' File changelogFile = new File(System.getenv("CHANGELOG_FILE") ?: "CHANGELOG.md") @@ -1193,7 +1191,7 @@ if (curseForgeProjectId.size() != 0) { options { javaIntegration = false forgeGradleIntegration = false - debug = true + debug = false } } @@ -1211,7 +1209,7 @@ if (curseForgeProjectId.size() != 0) { addCurseForgeRelation("requiredDependency", "unimixins") } tasks.curseforge.dependsOn(build) - tasks.publishMNCF.dependsOn(tasks.curseforge) + tasks.publish.dependsOn(tasks.curseforge) } def addModrinthDep(String scope, String type, String name) { diff --git a/gradle.properties b/gradle.properties index 2b4faab..7af260a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -91,6 +91,12 @@ relocateShadowedDependencies = true # Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories includeWellKnownRepositories = true +# Publishing to modrinth requires you to set the MAVEN_USER and MAVEN_PASSWORD environment variables. + +# URL of the maven to publish to. +# 'allowInsecureProtocol' is set to 'true' if the URL starts with "http://" (it is not recommended to use HTTPS unencrypted though). +# mavenURL = http://jenkins.usrv.eu:8081/nexus/content/repositories/releases + # Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token. # The project's ID on Modrinth. Can be either the slug or the ID.