ソースを参照

Publish to CF

shedaniel 4 年 前
コミット
6362fe40e3

+ 4 - 3
.github/workflows/publish.yml

@@ -1,7 +1,7 @@
 name: Java CI
 
 on:
-  [push]
+  [ push ]
 
 jobs:
   build:
@@ -13,7 +13,8 @@ jobs:
         with:
           java-version: 1.8
       - name: Upload to Bintray
-        run: ./gradlew bintrayUpload --stacktrace
+        run: ./gradlew bintrayUpload curseforgePublish --stacktrace
         env:
           BINTRAY_USER: shedaniel
-          BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
+          BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
+          curse_api_key: ${{ secrets.CURSE_API_KEY }}

+ 34 - 0
build.gradle

@@ -2,6 +2,7 @@ plugins {
     id "architect-plugin" version "1.1.15"
     id "org.cadixdev.licenser" version "0.5.0"
     id "com.jfrog.bintray" version "1.8.4"
+    id "com.matthewprenger.cursegradle" version "1.4.0" apply false
     id "maven"
     id "maven-publish"
 }
@@ -55,4 +56,37 @@ bintray {
             vcsUrl = "https://github.com/shedaniel/architectury.git"
         }
     }
+}
+
+def releaseChangelog = "No changelog"
+task curseforgePublish {
+    def dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm")
+    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
+    def branch
+    if (System.env.BRANCH_NAME) {
+        branch = System.env.BRANCH_NAME
+        branch = branch.substring(branch.lastIndexOf("/") + 1)
+    } else {
+        branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
+    }
+    if (branch == "HEAD") {
+        branch = "git rev-parse --short HEAD".execute().in.text.trim()
+    }
+    def time = dateFormat.format(new Date())
+    def changes = new StringBuilder()
+    changes << "<h2>Architectury v$project.version for $project.supported_version</h2>Updated at <b>$time</b>.<br><a href=\"https://www.github.com/architectury/architectury/commits/$branch\">Click here for changelog</a>"
+    def proc = "git log --max-count=200 --pretty=format:%s".execute()
+    proc.in.eachLine { line ->
+        def processedLine = line.toString()
+        if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
+            changes << "<br>- ${processedLine.capitalize()}"
+        }
+    }
+    proc.waitFor()
+    releaseChangelog = changes.toString()
+}
+
+afterEvaluate {
+//    curseforgePublish.dependsOn project("fabric").tasks.getByName("curseforge")
+//    curseforgePublish.dependsOn project("forge").tasks.getByName("curseforge")
 }

+ 31 - 1
fabric/build.gradle

@@ -1,6 +1,7 @@
 plugins {
     id "fabric-loom"
     id "com.github.johnrengelman.shadow" version "5.0.0"
+    id "com.matthewprenger.cursegradle"
 }
 
 loom {
@@ -53,10 +54,39 @@ remapJar {
 publishing {
     publications {
         mavenFabric(MavenPublication) {
-            artifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-fabric.jar")) {
+            artifact(remapJar.archivePath) {
                 builtBy build
                 classifier "fabric"
             }
         }
     }
+}
+
+curseforge {
+    if (project.hasProperty("curse_api_key") || System.getenv("curse_api_key") != null) {
+        apiKey = project.hasProperty("curse_api_key") ? project.property("curse_api_key") : System.getenv("curse_api_key")
+        project {
+            id = "419697"
+            releaseType = "release"
+            changelogType = "html"
+            changelog = rootProject.releaseChangelog
+            addGameVersion "1.16-Snapshot"
+            addGameVersion "1.16.4"
+            addGameVersion "Java 8"
+            addGameVersion "Fabric"
+            relations {
+                requiredDependency "fabric-api"
+            }
+            mainArtifact(remapJar.archivePath.toFile()) {
+                displayName = "[Fabric $rootProject.supported_version] v$project.version"
+            }
+            afterEvaluate {
+                uploadTask.dependsOn("build")
+            }
+        }
+    }
+    options {
+        forgeGradleIntegration = false
+        javaVersionAutoDetect = false
+    }
 }

+ 1 - 1
fabric/src/main/resources/fabric.mod.json

@@ -22,6 +22,6 @@
   },
   "accessWidener": "architectury.accessWidener",
   "depends": {
-    "minecraft": ">=1.16.2"
+    "minecraft": ">=1.16.4"
   }
 }

+ 30 - 1
forge/build.gradle

@@ -12,6 +12,7 @@ buildscript {
 plugins {
     id "com.github.johnrengelman.shadow" version "5.0.0"
     id "eclipse"
+    id "com.matthewprenger.cursegradle"
 }
 
 apply plugin: "net.minecraftforge.gradle"
@@ -73,10 +74,38 @@ reobf {
 publishing {
     publications {
         mavenForge(MavenPublication) {
-            artifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-forge.jar")) {
+            artifact(shadowJar.archivePath) {
                 builtBy shadowJar
                 classifier "forge"
             }
         }
     }
+}
+
+curseforge {
+    if (project.hasProperty("curse_api_key") || System.getenv("curse_api_key") != null) {
+        apiKey = project.hasProperty("curse_api_key") ? project.property("curse_api_key") : System.getenv("curse_api_key")
+        project {
+            id = "419699"
+            releaseType = "release"
+            changelogType = "html"
+            changelog = rootProject.releaseChangelog
+            addGameVersion "1.16.4"
+            addGameVersion "Java 8"
+            addGameVersion "Forge"
+            relations {
+                requiredDependency "fabric-api"
+            }
+            mainArtifact(shadowJar.archivePath.toFile()) {
+                displayName = "[Forge $rootProject.supported_version] v$project.version"
+            }
+            afterEvaluate {
+                uploadTask.dependsOn("build")
+            }
+        }
+    }
+    options {
+        forgeGradleIntegration = false
+        javaVersionAutoDetect = false
+    }
 }

+ 1 - 1
forge/src/main/resources/META-INF/mods.toml

@@ -1,5 +1,5 @@
 modLoader = "javafml"
-loaderVersion = "[32,)"
+loaderVersion = "[33,)"
 issueTrackerURL = "https://github.com/shedaniel/architectury/issues"
 license = "Apache-2.0"
 

+ 1 - 0
gradle.properties

@@ -2,6 +2,7 @@ org.gradle.jvmargs=-Xmx3G
 org.gradle.daemon=false
 
 minecraft_version=1.16.4
+supported_version=1.16.4
 
 archives_base_name=architectury
 mod_version=1.0