@@ -67,19 +67,95 @@ tasks.withType(JavaCompile).configureEach {
6767 it. options. release = 21
6868}
6969
70- // Configure Maven publishing.
70+
71+
72+
7173publishing {
7274 publications {
73- mavenJava(MavenPublication ) {
75+ // Modified by TeaCon
76+ register(' release' , MavenPublication ) {
77+ // noinspection GroovyAssignabilityCheck
7478 from components. java
79+ version = rootProject. mod_version
80+ groupId = rootProject. maven_group
81+ artifactId = " $mod_github_repo -$rootProject . minecraft_version "
82+ pom {
83+ name = mod_github_repo
84+ url = " https://github.com/$mod_github_owner /$mod_github_repo "
85+ licenses {
86+ license {
87+ name = mod_license
88+ url = " https://github.com/$mod_github_owner /$mod_github_repo /blob/HEAD/LICENSE"
89+ }
90+ }
91+ organization {
92+ name = ' TeaConMC'
93+ url = ' https://github.com/teaconmc'
94+ }
95+ developers {
96+ for (mod_author in " $mod_authors " . split(' ,' )) {
97+ developer { id = mod_author. trim(); name = mod_author. trim() }
98+ }
99+ }
100+ issueManagement {
101+ system = ' GitHub Issues'
102+ url = " https://github.com/$mod_github_owner /$mod_github_repo /issues"
103+ }
104+ scm {
105+ url = " https://github.com/$mod_github_owner /$mod_github_repo "
106+ connection = " scm:git:git://github.com/$mod_github_owner /${ mod_github_repo} .git"
107+ developerConnection = " scm:git:git@github.com:$mod_github_owner /${ mod_github_repo} .git"
108+ }
109+ }
75110 }
76111 }
77-
78- // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
79112 repositories {
80- // Add repositories to publish to here.
81- // Notice: This block does NOT have the same function as the block in the top level.
82- // The repositories here will be used for publishing your artifact, not for
83- // retrieving dependencies.
113+ // Modified by TeaCon
114+ maven {
115+ name " teacon"
116+ url " s3://maven/"
117+ credentials(AwsCredentials ) {
118+ accessKey = System . env. ARCHIVE_ACCESS_KEY
119+ secretKey = System . env. ARCHIVE_SECRET_KEY
120+ }
121+ }
122+ }
123+ }
124+
125+ // Added by TeaCon
126+ tasks. withType(PublishToMavenRepository ). configureEach {
127+ if (repository && repository. name == " archive" ) {
128+ it. onlyIf {
129+ System . env. MAVEN_USERNAME && System . env. MAVEN_PASSWORD
130+ }
84131 }
85132}
133+
134+ abstract class TeaConDumpPathToGitHub extends DefaultTask {
135+ @Input
136+ abstract Property<String > getPublishName ()
137+ @InputFile
138+ abstract RegularFileProperty getTargetFile ()
139+ @TaskAction
140+ void dump () {
141+ if (System . env. GITHUB_ACTIONS ) {
142+ File theFile = targetFile. getAsFile(). get()
143+
144+ def outputFile = new File (System . env. GITHUB_OUTPUT )
145+ // Use the env-specific line separator for maximally possible compatibility
146+ def newLine = System . getProperty(' line.separator' )
147+
148+ // Write out new env variable for later usage
149+ outputFile << newLine << " artifact_name=${ theFile.getName()} "
150+ outputFile << newLine << " artifact_publish_name=${ publishName.get()} "
151+ outputFile << newLine << " artifact_path=${ theFile.absolutePath} "
152+ }
153+ }
154+ }
155+
156+ // Added by TeaCon
157+ tasks. register(" githubActionOutput" , TeaConDumpPathToGitHub ) { task ->
158+ task. onlyIf { System . env. GITHUB_ACTIONS }
159+ task. getTargetFile(). set(jar. archiveFile)
160+ task. getPublishName(). set(" ${ jar.archiveBaseName.get()} -${ version} .jar" )
161+ }
0 commit comments