Skip to content

Commit aff7cfa

Browse files
committed
feat: publishing
1 parent 52fdc7a commit aff7cfa

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

.github/workflows/release-dev.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,19 @@ jobs:
4747
id: commit_hash
4848
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
4949

50+
- name: Publish to SimpleCloud Repository
51+
run: ./gradlew publishMavenJavaPublicationToSimplecloudRepository
52+
env:
53+
COMMIT_HASH: ${{ env.COMMIT_HASH }}
54+
SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }}
55+
SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }}
56+
5057
- name: Publish to Modrinth
5158
run: ./gradlew modrinth && ./gradlew modrinthSyncBody
5259
env:
5360
COMMIT_HASH: ${{ env.COMMIT_HASH }}
5461
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
62+
5563
- name: Create Release
5664
id: create_release
5765
uses: actions/create-release@v1

build.gradle.kts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ plugins {
55
id("java")
66
alias(libs.plugins.shadow)
77
alias(libs.plugins.kotlin.jvm)
8+
alias(libs.plugins.sonatype.central.portal.publisher)
9+
`maven-publish`
810
}
911

10-
group = "app.simplecloud.api"
11-
version = "1.0-SNAPSHOT"
12+
val baseVersion = "0.0.1"
13+
val commitHash = System.getenv("COMMIT_HASH")
14+
val timestamp = System.currentTimeMillis() // Temporary to be able to build and publish directly out of fix branch with same commit hash
15+
val snapshotVersion = "${baseVersion}-dev.${timestamp}-${commitHash}"
1216

1317
allprojects {
18+
group = "app.simplecloud.plugin"
19+
version = if (commitHash != null) snapshotVersion else baseVersion
20+
1421
repositories {
1522
mavenCentral()
1623
mavenLocal()
@@ -19,7 +26,6 @@ allprojects {
1926
maven("https://repo.simplecloud.app/snapshots")
2027
maven("https://buf.build/gen/maven")
2128
}
22-
2329
}
2430

2531
tasks.named("shadowJar", ShadowJar::class).configure {
@@ -30,7 +36,9 @@ subprojects {
3036
apply {
3137
plugin(rootProject.libs.plugins.shadow.get().pluginId)
3238
plugin(rootProject.libs.plugins.kotlin.jvm.get().pluginId)
39+
plugin(rootProject.libs.plugins.sonatype.central.portal.publisher.get().pluginId)
3340
}
41+
3442
java {
3543
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
3644
}
@@ -42,4 +50,35 @@ subprojects {
4250
jvmTarget.set(JvmTarget.JVM_21)
4351
}
4452
}
53+
54+
publishing {
55+
repositories {
56+
maven {
57+
name = "simplecloud"
58+
url = uri("https://repo.simplecloud.app/snapshots/")
59+
credentials {
60+
username = System.getenv("SIMPLECLOUD_USERNAME")?: (project.findProperty("simplecloudUsername") as? String)
61+
password = System.getenv("SIMPLECLOUD_PASSWORD")?: (project.findProperty("simplecloudPassword") as? String)
62+
}
63+
authentication {
64+
create<BasicAuthentication>("basic")
65+
}
66+
}
67+
}
68+
69+
publications {
70+
create<MavenPublication>("mavenJava") {
71+
from(components["java"])
72+
}
73+
}
74+
}
75+
76+
signing {
77+
if (commitHash != null) {
78+
return@signing
79+
}
80+
81+
sign(publishing.publications)
82+
useGpgCmd()
83+
}
4584
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ simplecloud-controller = "0.0.30-SNAPSHOT.2660ec8"
88
simplecloud-player = "0.0.1-SNAPSHOT.d490b2f"
99
paper = "1.21.4-R0.1-SNAPSHOT"
1010
minotaur = "2.8.7"
11+
sonatype-central-portal-publisher = "1.2.3"
1112

1213
[libraries]
1314
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
@@ -22,4 +23,5 @@ bungeecord = { module = "net.md-5:bungeecord-api", version.ref = "bungeecord" }
2223
[plugins]
2324
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
2425
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
26+
sonatype-central-portal-publisher = { id = "net.thebugmc.gradle.sonatype-central-portal-publisher", version.ref = "sonatype-central-portal-publisher" }
2527
minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" }

0 commit comments

Comments
 (0)