From 6f8dfbb3f7fdfe9254cc578a2aa78536976c8f80 Mon Sep 17 00:00:00 2001
From: modmuss50 <modmuss50@gmail.com>
Date: Thu, 25 Nov 2021 15:06:25 +0000
Subject: [PATCH] Update loom and misc buildscript fixes (#1864)

Fixes sources not being published to maven.
---
 .github/workflows/build.yml   |  4 ++++
 .github/workflows/release.yml |  6 +++++-
 build.gradle                  | 15 +++++----------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1e53e949d..a30174eaf 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,3 +25,7 @@ jobs:
         with:
           name: Artifacts
           path: ./*/build/libs/
+      - uses: actions/upload-artifact@v2
+        with:
+          name: Maven Local
+          path: /root/.m2/repository
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8b38e053f..1503cb318 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,5 +1,9 @@
 name: Release
 on: [workflow_dispatch] # Manual trigger
+
+permissions:
+  contents: write
+
 jobs:
   build:
     runs-on: ubuntu-20.04
@@ -23,6 +27,6 @@ jobs:
           MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
           MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
           CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
-          GITHUB_TOKEN: ${{ secrets.GH_API_KEY }}
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
           CHANGELOG: ${{ steps.changelog.outputs.changelog }}
diff --git a/build.gradle b/build.gradle
index 264d1e7e9..d49f29f40 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ plugins {
 	id "eclipse"
 	id "idea"
 	id "maven-publish"
-	id "fabric-loom" version "0.10.55" apply false
+	id "fabric-loom" version "0.10.60" apply false
 	id "org.cadixdev.licenser" version "0.6.1"
 	id "org.ajoberstar.grgit" version "3.1.0"
 	id "com.matthewprenger.cursegradle" version "1.4.0"
@@ -132,9 +132,8 @@ allprojects {
 		include "**/*.java"
 	}
 
-	task sourcesJar(type: Jar, dependsOn: classes) {
-		archiveClassifier = "sources"
-		from sourceSets.main.allSource
+	java {
+		withSourcesJar()
 	}
 
 	checkstyle {
@@ -242,10 +241,6 @@ subprojects {
 		genSourcesWithFernFlower.enabled = false
 		genSourcesWithCfr.enabled = false
 		unpickJar.enabled = false
-
-		// Work around a loom bug causing empty jars to be pushed to maven local.
-		publishMavenJavaPublicationToMavenLocal.dependsOn rootProject.tasks.getByName("remapAllJars")
-		publishMavenJavaPublicationToMavenLocal.dependsOn rootProject.tasks.getByName("remapAllSources")
 	}
 }
 
@@ -339,7 +334,7 @@ curseforge {
 	project {
 		id = "306612"
 		changelog = ENV.CHANGELOG ?: "No changelog provided"
-		releaseType = project.prerelease ? "beta" : "release"
+		releaseType = project.prerelease as Boolean ? "beta" : "release"
 		addGameVersion "1.18-Snapshot"
 		addGameVersion "Fabric"
 
@@ -389,7 +384,7 @@ task modrinth(type: com.modrinth.minotaur.TaskModrinthUpload, dependsOn: remapMa
 	projectId = "P7dR8mSH"
 	versionNumber = version
 	versionName = "[$project.minecraft_version] Fabric API $project.version"
-	releaseType = project.prerelease ? "beta" : "release"
+	releaseType = project.prerelease as Boolean ? "beta" : "release"
 	changelog = ENV.CHANGELOG ?: "No changelog provided"
 
 	uploadFile = remapJar