mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Jar and PGP sign artifacts. (#2062)
* Jar and PGP sign artifacts.
* Fixes.
* Update remotesign and fixes.
* Update gradle.
* Revert "Update gradle."
This reverts commit 91b96ec2db
.
This commit is contained in:
parent
40c91ec8c3
commit
5ceae78bef
2 changed files with 79 additions and 13 deletions
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
|
@ -30,3 +30,6 @@ jobs:
|
|||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
CHANGELOG: ${{ steps.changelog.outputs.changelog }}
|
||||
SIGNING_SERVER: ${{ secrets.SIGNING_SERVER }}
|
||||
SIGNING_PGP_KEY: ${{ secrets.SIGNING_PGP_KEY }}
|
||||
SIGNING_JAR_KEY: ${{ secrets.SIGNING_JAR_KEY }}
|
||||
|
|
89
build.gradle
89
build.gradle
|
@ -9,14 +9,16 @@ plugins {
|
|||
id "eclipse"
|
||||
id "idea"
|
||||
id "maven-publish"
|
||||
id "fabric-loom" version "0.11.27" apply false
|
||||
id "fabric-loom" version "0.11.32" 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"
|
||||
id "com.modrinth.minotaur" version "1.1.0"
|
||||
id "me.modmuss50.remotesign" version "0.2.4" apply false
|
||||
}
|
||||
|
||||
def ENV = System.getenv()
|
||||
def signingEnabled = ENV.SIGNING_SERVER
|
||||
|
||||
version = project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
|
||||
logger.lifecycle("Building Fabric: " + version)
|
||||
|
@ -66,6 +68,24 @@ def moduleDependencies(project, List<String> depNames) {
|
|||
api it
|
||||
}
|
||||
}
|
||||
|
||||
// As we manually handle the maven artifacts, we need to also manually specify the deps.
|
||||
project.publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
pom.withXml {
|
||||
def depsNode = asNode().appendNode("dependencies")
|
||||
deps.each {
|
||||
def depNode = depsNode.appendNode("dependency")
|
||||
depNode.appendNode("groupId", it.group)
|
||||
depNode.appendNode("artifactId", it.name)
|
||||
depNode.appendNode("version", it.version)
|
||||
depNode.appendNode("scope", "compile")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
@ -74,6 +94,7 @@ allprojects {
|
|||
apply plugin: "maven-publish"
|
||||
apply plugin: "fabric-loom"
|
||||
apply plugin: "org.cadixdev.licenser"
|
||||
apply plugin: "me.modmuss50.remotesign"
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 17
|
||||
|
@ -151,6 +172,21 @@ allprojects {
|
|||
tasks.withType(GenerateModuleMetadata) {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
if (signingEnabled) {
|
||||
remoteSign {
|
||||
requestUrl = ENV.SIGNING_SERVER
|
||||
pgpAuthKey = ENV.SIGNING_PGP_KEY
|
||||
jarAuthKey = ENV.SIGNING_JAR_KEY
|
||||
|
||||
sign remapJar
|
||||
|
||||
afterEvaluate {
|
||||
// PGP sign all maven publications.
|
||||
sign publishing.publications.mavenJava
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply auxiliary buildscripts to submodules
|
||||
|
@ -236,13 +272,22 @@ subprojects {
|
|||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
artifact(signingEnabled ? signRemapJar.output : remapJar) {
|
||||
builtBy(signingEnabled ? signRemapJar : remapJar)
|
||||
}
|
||||
|
||||
artifact(remapSourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setupRepositories(repositories)
|
||||
}
|
||||
|
||||
// We manually handle the pom generation
|
||||
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
|
||||
|
||||
javadoc.enabled = false
|
||||
|
||||
afterEvaluate {
|
||||
|
@ -260,11 +305,17 @@ task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
|
|||
}
|
||||
build.dependsOn remapMavenJar
|
||||
|
||||
if (signingEnabled) {
|
||||
remoteSign {
|
||||
sign remapMavenJar
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact(remapMavenJar) {
|
||||
builtBy remapMavenJar
|
||||
artifact(signingEnabled ? signRemapMavenJar.output : remapMavenJar) {
|
||||
builtBy(signingEnabled ? signRemapMavenJar : remapMavenJar)
|
||||
}
|
||||
|
||||
artifact(sourcesJar) {
|
||||
|
@ -327,15 +378,22 @@ dependencies {
|
|||
subprojects.each {
|
||||
api project(path: ":${it.name}", configuration: "namedElements")
|
||||
|
||||
if (!(it.name in devOnlyModules)) {
|
||||
include project("${it.name}:")
|
||||
}
|
||||
|
||||
testmodImplementation project("${it.name}:").sourceSets.testmod.output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remapJar {
|
||||
afterEvaluate {
|
||||
subprojects.each {
|
||||
if (it.name in devOnlyModules) return
|
||||
|
||||
// Include the signed or none signed jar from the sub project.
|
||||
nestedJars.from project("${it.name}:").tasks.getByName(signingEnabled ? "signRemapJar" : "remapJar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curseforge {
|
||||
if (ENV.CURSEFORGE_API_KEY) {
|
||||
apiKey = ENV.CURSEFORGE_API_KEY
|
||||
|
@ -348,7 +406,7 @@ curseforge {
|
|||
addGameVersion "1.18.2"
|
||||
addGameVersion "Fabric"
|
||||
|
||||
mainArtifact(remapJar) {
|
||||
mainArtifact(signingEnabled ? signRemapJar.output : remapJar) {
|
||||
displayName = "[$project.minecraft_version] Fabric API $project.version"
|
||||
}
|
||||
|
||||
|
@ -362,10 +420,15 @@ curseforge {
|
|||
}
|
||||
}
|
||||
|
||||
if (signingEnabled) {
|
||||
project.tasks.curseforge.dependsOn signRemapJar
|
||||
build.dependsOn signRemapJar
|
||||
}
|
||||
|
||||
import org.kohsuke.github.GHReleaseBuilder
|
||||
import org.kohsuke.github.GitHub
|
||||
|
||||
task github(dependsOn: remapMavenJar) {
|
||||
task github(dependsOn: (signingEnabled ? signRemapJar : remapJar)) {
|
||||
onlyIf {
|
||||
ENV.GITHUB_TOKEN
|
||||
}
|
||||
|
@ -381,11 +444,11 @@ task github(dependsOn: remapMavenJar) {
|
|||
releaseBuilder.prerelease(project.prerelease == "true")
|
||||
|
||||
def ghRelease = releaseBuilder.create()
|
||||
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
|
||||
ghRelease.uploadAsset(signingEnabled ? signRemapJar.output.get().getAsFile() : remapJar.archiveFile.get().getAsFile(), "application/java-archive");
|
||||
}
|
||||
}
|
||||
|
||||
task modrinth(type: com.modrinth.minotaur.TaskModrinthUpload, dependsOn: remapMavenJar) {
|
||||
task modrinth(type: com.modrinth.minotaur.TaskModrinthUpload, dependsOn: (signingEnabled ? signRemapJar : remapJar)) {
|
||||
onlyIf {
|
||||
ENV.MODRINTH_TOKEN
|
||||
}
|
||||
|
@ -397,7 +460,7 @@ task modrinth(type: com.modrinth.minotaur.TaskModrinthUpload, dependsOn: remapMa
|
|||
releaseType = project.prerelease == "true" ? "beta" : "release"
|
||||
changelog = ENV.CHANGELOG ?: "No changelog provided"
|
||||
|
||||
uploadFile = remapJar
|
||||
uploadFile = signingEnabled ? signRemapJar.output : remapJar
|
||||
|
||||
addGameVersion(project.minecraft_version)
|
||||
addLoader('fabric')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue