Skip to content

Commit ff47698

Browse files
committed
(ci&build) clean up build scripts & minor change on package publish workflow
1 parent ca4084c commit ff47698

File tree

2 files changed

+24
-42
lines changed

2 files changed

+24
-42
lines changed

.github/workflows/maven-publish-ghpkg.yml renamed to .github/workflows/package-publish.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,5 @@ jobs:
3838
- name: Publish to GitHub Packages Apache Maven
3939
run: ./gradlew publish -i
4040
env:
41-
BUILD_NUMBER: ${{github.run_number}}
42-
MAVEN_DIR: https://maven.pkg.github.com/${{github.repository}}
43-
MAVEN_USERNAME: ${{github.actor}}
44-
MAVEN_PASSWORD: ${{secrets.GITHUB_TOKEN}}
41+
GITHUB_MAVEN_URL: https://maven.pkg.github.com/${{github.repository}}
42+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

build.gradle.kts

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import io.papermc.paperweight.util.path
2-
import java.util.*
1+
import java.net.URI
32

43
plugins {
54
`java-library`
@@ -11,22 +10,12 @@ plugins {
1110
// = = =
1211

1312
val pluginName = "NyaaCore"
14-
val majorVersion = 9
15-
val minorVersion = 4
16-
17-
val paperApiName = "1.21-R0.1-SNAPSHOT"
13+
val paperApiName = "1.21.1-R0.1-SNAPSHOT"
1814

1915
// = = =
2016

21-
// for Jenkins CI
22-
val buildNumber = System.getenv("BUILD_NUMBER") ?: "x"
23-
val mavenDirectory = System.getenv("MAVEN_DIR") ?: layout.buildDirectory.dir("repo").path.toString()
24-
val javaDocDirectory = System.getenv("JAVADOC_DIR") ?: layout.buildDirectory.dir("javadoc").path.toString()
25-
26-
// Version used for distribution. Different from maven repo
2717
group = "cat.nyaa"
28-
//archivesBaseName = "${pluginNameUpper}-mc$minecraftVersion"
29-
version ="$majorVersion.$minorVersion"
18+
version ="9.4"
3019

3120
java {
3221
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 8 installed for example.
@@ -35,19 +24,14 @@ java {
3524

3625
repositories {
3726
mavenCentral()
38-
maven {
39-
url = uri("https://papermc.io/repo/repository/maven-public/")
40-
} //paper
41-
maven { url = uri("https://libraries.minecraft.net") } // mojang
42-
maven { url = uri("https://repo.essentialsx.net/releases/") } // essentials
27+
maven ("https://papermc.io/repo/repository/maven-public/") //paper
28+
maven ("https://libraries.minecraft.net") // mojang
29+
maven ("https://repo.essentialsx.net/releases/") // essentials
4330
// maven { url = uri("https://ci.nyaacat.com/maven/") } // nyaacat
44-
4531
}
4632

4733
dependencies {
4834
paperweight.paperDevBundle(paperApiName)
49-
// paperweight.foliaDevBundle("1.21-R0.1-SNAPSHOT")
50-
// paperweight.devBundle("com.example.paperfork", "1.21-R0.1-SNAPSHOT")
5135
compileOnly("net.essentialsx:EssentialsX:2.20.1") // soft dep
5236
compileOnly("org.jetbrains:annotations:24.1.0")
5337
// Testing
@@ -66,20 +50,16 @@ publishing {
6650
from(components["java"])
6751
groupId = group.toString()
6852
artifactId = pluginName.lowercase()
69-
version = "$majorVersion.$minorVersion.$buildNumber-mc${getMcVersion(paperApiName)}"
53+
version = project.version.toString()
7054
}
7155
}
7256
repositories {
7357
maven {
74-
name = "PublishMaven"
75-
url = uri(mavenDirectory)
76-
val mavenUserName = System.getenv("MAVEN_USERNAME")
77-
val mavenPassword = System.getenv("MAVEN_PASSWORD")
78-
if(mavenUserName != null && mavenPassword != null) {
79-
credentials {
80-
username = mavenUserName
81-
password = mavenPassword
82-
}
58+
name = "github-package"
59+
url = URI(System.getenv("GITHUB_MAVEN_URL") ?: "https://github.com")
60+
credentials {
61+
username = System.getenv("GITHUB_ACTOR")
62+
password = System.getenv("GITHUB_TOKEN")
8363
}
8464
}
8565
}
@@ -95,23 +75,26 @@ reobfJar {
9575

9676

9777
tasks {
98-
78+
// ref: https://docs.papermc.io/paper/dev/userdev
9979
// 1)
10080
// For >=1.20.5 when you don't care about supporting spigot
101-
// paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION
81+
// set:
82+
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION
83+
// and it will eliminate the -dev suffix from the artifact name which indicates the artifact is
84+
// mojang-mapped and won't work on the most of the server but at 1.20.5 the paper
85+
// uses mojang-mapping by default, so it doesn't matter anymore.
86+
//
10287

10388
// 2)
10489
// For 1.20.4 or below, or when you care about supporting Spigot on >=1.20.5
10590
// Configure reobfJar to run when invoking the build task
10691
/*
107-
// Configure reobfJar to run when invoking the build task
10892
assemble {
10993
dependsOn(reobfJar)
11094
}
11195
*/
11296

11397
withType<ProcessResources> {
114-
11598
val newProperties = project.properties.toMutableMap()
11699
newProperties["api_version"] = getMcVersion(paperApiName)
117100
filesMatching("plugin.yml") {
@@ -121,7 +104,6 @@ tasks {
121104

122105
compileJava {
123106
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
124-
125107
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
126108
// See https://openjdk.java.net/jeps/247 for more information.
127109
options.release.set(21)
@@ -158,5 +140,7 @@ tasks {
158140
}
159141

160142
private fun getMcVersion(apiNameString: String): String {
161-
return apiNameString.split('-')[0]
143+
val version = apiNameString.split('-')[0]
144+
val versionInArray = version.split('.')
145+
return "${versionInArray[0]}.${versionInArray[1]}"
162146
}

0 commit comments

Comments
 (0)