Skip to content

Commit 94b09be

Browse files
committed
build: migrate CI and publishing to Maven Central
1 parent 38f04d9 commit 94b09be

10 files changed

Lines changed: 128 additions & 182 deletions

File tree

.github/workflows/deploy-release.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/deploy-snapshot.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/gradle.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Protocol
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- .github/workflows/gradle.yml
8+
- gradle/**
9+
- gradlew
10+
- gradlew.bat
11+
- gradle.properties
12+
- settings.gradle.kts
13+
- build.gradle.kts
14+
- common/**
15+
- bedrock-codec/**
16+
- bedrock-connection/**
17+
pull_request:
18+
paths:
19+
- .github/workflows/gradle.yml
20+
- gradle/**
21+
- gradlew
22+
- gradlew.bat
23+
- gradle.properties
24+
- settings.gradle.kts
25+
- build.gradle.kts
26+
- common/**
27+
- bedrock-codec/**
28+
- bedrock-connection/**
29+
30+
jobs:
31+
build:
32+
runs-on: ubuntu-latest
33+
timeout-minutes: 10
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v6
37+
38+
- name: Setup Java
39+
uses: actions/setup-java@v5
40+
with:
41+
java-version: '21'
42+
distribution: 'zulu'
43+
44+
- name: Validate Gradle Wrapper
45+
uses: gradle/actions/wrapper-validation@v4
46+
47+
- name: Setup Gradle
48+
uses: gradle/actions/setup-gradle@v6
49+
with:
50+
gradle-version: wrapper
51+
cache-overwrite-existing: true
52+
cache-read-only: false
53+
build-scan-publish: true
54+
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
55+
build-scan-terms-of-use-agree: "yes"
56+
57+
- name: Build
58+
run: |
59+
chmod +x gradlew
60+
./gradlew build
61+
62+
- name: Publish to Maven Central
63+
if: success() && github.event_name == 'push' && github.repository == 'AllayMC/Protocol' && github.ref_name == 'main'
64+
run: |
65+
./gradlew :common:publishToMavenCentral
66+
./gradlew :bedrock-codec:publishToMavenCentral
67+
./gradlew :bedrock-connection:publishToMavenCentral
68+
env:
69+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
70+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
71+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SONATYPE_SECRET_KEY }}
72+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SONATYPE_SECRET_KEY_PASSWORD }}

.github/workflows/pull-request.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

bedrock-codec/build.gradle.kts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,5 @@ dependencies {
1010

1111
// Tests
1212
testImplementation(libs.junit)
13-
}
14-
15-
tasks.jar {
16-
manifest {
17-
attributes("Automatic-Module-Name" to "org.cloudburstmc.protocol.bedrock.codec")
18-
}
13+
testRuntimeOnly(libs.junit.platform.launcher)
1914
}

bedrock-connection/build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@ dependencies {
33
api(libs.netty.transport.raknet)
44
api(libs.snappy)
55
}
6-
7-
tasks.jar {
8-
manifest {
9-
attributes("Automatic-Module-Name" to "org.cloudburstmc.protocol.bedrock.connection")
10-
}
11-
}

build.gradle.kts

Lines changed: 53 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
1-
import org.gradle.api.tasks.javadoc.Javadoc
2-
import org.gradle.external.javadoc.StandardJavadocDocletOptions
3-
import org.gradle.kotlin.dsl.compileJava
4-
import org.gradle.kotlin.dsl.invoke
5-
6-
@Suppress("DSL_SCOPE_VIOLATION") // https://youtrack.jetbrains.com/issue/IDEA-262280
1+
import com.vanniktech.maven.publish.MavenPublishBaseExtension
72

83
plugins {
94
id("java-library")
10-
id("maven-publish")
11-
id("signing")
12-
alias(libs.plugins.lombok)
5+
alias(libs.plugins.lombok) apply false
6+
alias(libs.plugins.publish) apply false
137
}
148

159
tasks.jar {
1610
enabled = false
1711
}
1812

1913
subprojects {
14+
apply(plugin = "java-library")
15+
apply(plugin = rootProject.libs.plugins.lombok.get().pluginId)
16+
apply(plugin = rootProject.libs.plugins.publish.get().pluginId)
2017

21-
apply {
22-
plugin("java-library")
23-
plugin("maven-publish")
24-
plugin("signing")
25-
plugin(rootProject.libs.plugins.lombok.get().pluginId)
26-
}
27-
28-
group = "org.cloudburstmc.protocol"
18+
group = "org.allaymc.protocol"
19+
version = rootProject.version
2920

3021
tasks {
31-
compileJava {
32-
options.encoding = Charsets.UTF_8.name();
22+
withType<JavaCompile>().configureEach {
23+
options.encoding = Charsets.UTF_8.name()
3324
options.compilerArgs.add("-parameters")
3425
}
26+
3527
withType<Javadoc>().configureEach {
3628
(options as StandardJavadocDocletOptions).addBooleanOption("Xdoclint:-missing", true)
3729
}
30+
3831
test {
3932
useJUnitPlatform()
4033
}
4134
}
4235

36+
repositories {
37+
mavenCentral()
38+
maven("https://repo.opencollab.dev/maven-releases/")
39+
maven("https://repo.opencollab.dev/maven-snapshots/")
40+
}
41+
4342
dependencies {
4443
compileOnly(rootProject.libs.checker.qual)
4544
}
@@ -52,57 +51,46 @@ subprojects {
5251
}
5352
}
5453

55-
publishing {
56-
repositories {
57-
maven {
58-
name = "maven-deploy"
59-
url = uri(
60-
System.getenv("MAVEN_DEPLOY_URL")
61-
?: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
62-
)
63-
credentials {
64-
username = System.getenv("MAVEN_DEPLOY_USERNAME") ?: "username"
65-
password = System.getenv("MAVEN_DEPLOY_PASSWORD") ?: "password"
66-
}
54+
configure<MavenPublishBaseExtension> {
55+
publishToMavenCentral()
56+
signAllPublications()
57+
58+
coordinates(
59+
project.group.toString(),
60+
project.name,
61+
project.version.toString()
62+
)
63+
64+
pom {
65+
name.set(project.name)
66+
description.set("A protocol library for Minecraft: Bedrock Edition that supports multiple versions.")
67+
url.set("https://github.com/AllayMC/Protocol")
68+
69+
scm {
70+
connection.set("scm:git:git://github.com/AllayMC/Protocol.git")
71+
developerConnection.set("scm:git:ssh://github.com/AllayMC/Protocol.git")
72+
url.set("https://github.com/AllayMC/Protocol")
6773
}
68-
}
6974

70-
publications {
71-
create<MavenPublication>("maven") {
72-
from(components["java"])
73-
pom {
74-
packaging = "jar"
75-
url.set("https://github.com/CloudburstMC/Protocol")
76-
77-
scm {
78-
connection.set("scm:git:git://github.com/CloudburstMC/Protocol.git")
79-
developerConnection.set("scm:git:ssh://github.com/CloudburstMC/Protocol.git")
80-
url.set("https://github.com/CloudburstMC/Protocol")
81-
}
82-
83-
licenses {
84-
license {
85-
name.set("The Apache Software License, Version 2.0")
86-
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
87-
}
88-
}
89-
90-
developers {
91-
developer {
92-
name.set("CloudburstMC Team")
93-
organization.set("CloudburstMC")
94-
organizationUrl.set("https://github.com/CloudburstMC")
95-
}
96-
}
75+
licenses {
76+
license {
77+
name.set("The Apache Software License, Version 2.0")
78+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
9779
}
9880
}
99-
}
100-
}
10181

102-
signing {
103-
if (System.getenv("PGP_SECRET") != null && System.getenv("PGP_PASSPHRASE") != null) {
104-
useInMemoryPgpKeys(System.getenv("PGP_SECRET"), System.getenv("PGP_PASSPHRASE"))
105-
sign(publishing.publications["maven"])
82+
developers {
83+
developer {
84+
name.set("CloudburstMC Team")
85+
organization.set("CloudburstMC")
86+
organizationUrl.set("https://github.com/CloudburstMC")
87+
}
88+
developer {
89+
name.set("AllayMC Team")
90+
organization.set("AllayMC")
91+
organizationUrl.set("https://github.com/AllayMC")
92+
}
93+
}
10694
}
10795
}
10896
}

common/build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,4 @@ dependencies {
55
api(libs.fastutil.`object`.int.maps)
66
api(libs.math)
77
api(libs.natives)
8-
}
9-
10-
tasks.jar {
11-
manifest {
12-
attributes("Automatic-Module-Name" to "org.cloudburstmc.protocol.common")
13-
}
148
}

gradle/libs.versions.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ junit = "5.9.2"
66

77
[libraries]
88
checker-qual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerframework" }
9-
checker = { group = "org.checkerframework", name = "checker", version.ref = "checkerframework" }
109
fastutil-bom = { group = "org.cloudburstmc.fastutil", name = "bom", version = "8.5.15" }
1110
fastutil-long-common = { group = "org.cloudburstmc.fastutil.commons", name = "long-common" }
1211
fastutil-long-object-maps = { group = "org.cloudburstmc.fastutil.maps", name = "long-object-maps" }
@@ -21,12 +20,12 @@ jose4j = { group = "org.bitbucket.b_c", name = "jose4j", version = "0.9.6" }
2120
natives = { group = "com.nukkitx", name = "natives", version = "1.0.3" }
2221
math = { group = "org.cloudburstmc.math", name = "immutable", version = "2.0-SNAPSHOT" }
2322
nbt = { group = "org.cloudburstmc", name = "nbt", version = "3.0.4.Final" }
24-
lmbda = { group = "org.lanternpowered", name = "lmbda", version = "2.0.0" }
2523

2624
snappy = { group = "io.airlift", name = "aircompressor", version = "0.27" }
2725

2826
junit = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
27+
junit-platform-launcher = { group = "org.junit.platform", name = "junit-platform-launcher", version = "1.9.2" }
2928

3029
[plugins]
31-
checkerframework = { id = "org.checkerframework", version = "0.6.29" }
3230
lombok = { id = "io.freefair.lombok", version = "9.2.0" }
31+
publish = { id = "com.vanniktech.maven.publish", version = "0.36.0" }

0 commit comments

Comments
 (0)