Skip to content

Commit

Permalink
勉强能用
Browse files Browse the repository at this point in the history
  • Loading branch information
3TUSK committed Jul 28, 2024
1 parent e863b61 commit 078a237
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
~/.gradle/wrapper
key: $${{ runner.os }}-gradle
- name: Get Short Identifier
uses: benjlevesque/short-sha@v1.2
uses: benjlevesque/short-sha@v3.0
id: short-sha
- name: Build
id: build
Expand Down
108 changes: 108 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ plugins {
id 'net.neoforged.moddev' version '1.0.15'
}

abstract class TeaConDumpPathToGitHub extends DefaultTask {
@Input
abstract Property<String> getPublishName()
@InputFile
abstract RegularFileProperty getTargetFile()
@TaskAction
void dump() {
if (System.env.GITHUB_ACTIONS) {
File theFile = targetFile.getAsFile().get()

def outputFile = new File(System.env.GITHUB_OUTPUT)
// Use the env-specific line separator for maximally possible compatibility
def newLine = System.getProperty('line.separator')

// Write out new env variable for later usage
outputFile << newLine << "artifact_name=${theFile.getName()}"
outputFile << newLine << "artifact_publish_name=${publishName.get()}"
outputFile << newLine << "artifact_path=${theFile.absolutePath}"
}
}
}

tasks.named('wrapper', Wrapper).configure {
distributionType = Wrapper.DistributionType.BIN
}
Expand Down Expand Up @@ -174,3 +196,89 @@ idea {
downloadJavadoc = true
}
}

publishing { PublishingExtension it ->
publications {
// noinspection GroovyAssignabilityCheck
release(MavenPublication) {
// noinspection GroovyAssignabilityCheck
from components.java
// noinspection GroovyAssignabilityCheck
groupId = "org.teacon"
// noinspection GroovyAssignabilityCheck
artifactId = 'PowerTool-1.21-NeoForge'
// noinspection GroovyAssignabilityCheck
version = mod_version
pom {
// noinspection GroovyAssignabilityCheck
name = 'PowerTool'
// noinspection GroovyAssignabilityCheck
url = "https://github.com/teaconmc/PowerTool"
licenses {
license {
// noinspection GroovyAssignabilityCheck
name = 'GPLv3'
// noinspection GroovyAssignabilityCheck
url = "https://github.com/teaconmc/PowerTool/blob/1.21-neoforge/LICENSE"
}
}
organization {
// noinspection GroovyAssignabilityCheck
name = 'TeaConMC'
// noinspection GroovyAssignabilityCheck
url = 'https://github.com/teaconmc'
}
developers {
developer {
id = '3TUSK'
name = '3TUSK'
}
developer {
id = 'xkball'
name = 'xkball'
}
}
issueManagement {
// noinspection GroovyAssignabilityCheck
system = 'GitHub Issues'
// noinspection GroovyAssignabilityCheck
url = "https://github.com/teaconmc/PowerTool/issues"
}
scm {
// noinspection GroovyAssignabilityCheck
url = "https://github.com/teaconmc/PowerTool"
// noinspection GroovyAssignabilityCheck
connection = "scm:git:git://github.com/teaconmc/PowerTool.git"
// noinspection GroovyAssignabilityCheck
developerConnection = "scm:git:[email protected]:teaconmc/PowerTool.git"
}
}
}
}
repositories {
maven {
name = "teacon"
url = "s3://maven/"
credentials(AwsCredentials) {
accessKey = System.env.ARCHIVE_ACCESS_KEY
secretKey = System.env.ARCHIVE_SECRET_KEY
}
}
}
}

tasks.withType(PublishToMavenRepository).configureEach {
if (repository && repository.name == "archive") {
it.onlyIf {
System.env.MAVEN_USERNAME && System.env.MAVEN_PASSWORD
}
}
}

tasks.register("githubActionOutput", TeaConDumpPathToGitHub) { task ->
task.onlyIf {
System.env.GITHUB_ACTIONS
}
task.getPublishName().set("${jar.archiveBaseName.get()}-${version}.jar")
task.getTargetFile().set(jar.archiveFile)
}
Loading

0 comments on commit 078a237

Please sign in to comment.