Skip to content

Commit 2a59868

Browse files
committed
Add auto publishing gradle plugin
1 parent fe6fbe8 commit 2a59868

5 files changed

Lines changed: 93 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
release:
10+
name: Publish Release
11+
runs-on: ubuntu-24.04
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Validate gradle wrapper
18+
uses: gradle/actions/wrapper-validation@v3
19+
20+
- name: Setup java 21
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: 21
24+
distribution: temurin
25+
26+
- name: Publish plugin
27+
env:
28+
GITHUB_API_TOKEN: ${{ github.token }}
29+
MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_PUBLISH_TOKEN }}
30+
run: ./gradlew publishMods --no-daemon -PnoDryPublish

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ A heavily configurable minecraft paper plugin for managing survival servers with
2929

3030
## Download
3131

32-
https://dl.cloudcraftmc.de/download/tool/craftattack
33-
34-
**Note: Depends on [CommandAPI](https://commandapi.jorel.dev/) and [CloudCore](https://github.com/CloudCraftProjects/CloudCore/).**
35-
Some features may require [LaunchPlates](https://github.com/CloudCraftProjects/LaunchPlates/) or [LuckPerms](https://luckperms.net/) to be installed.
32+
https://dl.cloudcraftmc.de/craftattack
33+
34+
> [!NOTE]
35+
> Depends
36+
> on [CommandAPI](https://modrinth.com/project/commandapi) and
37+
> [CloudCore](https://modrinth.com/project/cloudcore).<br>
38+
> Some features may require [LaunchPlates](https://modrinth.com/project/launchplates)
39+
> or [LuckPerms](https://luckperms.net/) to be installed.
3640
3741
## License
3842

build.gradle.kts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
import me.modmuss50.mpp.ModPublishExtension
2+
import me.modmuss50.mpp.PublishModTask
3+
14
plugins {
25
id("java-library")
36
id("maven-publish")
47

58
alias(libs.plugins.pluginyml.bukkit)
69
alias(libs.plugins.run.paper)
710
alias(libs.plugins.shadow)
11+
alias(libs.plugins.publishing)
812
}
913

1014
group = "dev.booky"
11-
version = "1.10.4-SNAPSHOT"
1215

1316
val plugin: Configuration by configurations.creating {
1417
isTransitive = false
@@ -91,3 +94,51 @@ tasks {
9194
dependsOn(shadowJar)
9295
}
9396
}
97+
98+
configure<ModPublishExtension> {
99+
val repositoryName = "CloudCraftProjects/CraftAttack"
100+
changelog = "See https://github.com/$repositoryName/releases/tag/v${project.version}"
101+
type = if (project.version.toString().endsWith("-SNAPSHOT")) BETA else STABLE
102+
dryRun = !hasProperty("noDryPublish")
103+
104+
file = tasks.named<Jar>("shadowJar").flatMap { it.archiveFile }
105+
additionalFiles.from(tasks.named<Jar>("sourcesJar"))
106+
107+
github {
108+
accessToken = providers.environmentVariable("GITHUB_API_TOKEN")
109+
.orElse(providers.gradleProperty("ccGithubToken"))
110+
111+
displayName = "${rootProject.name} v${project.version}"
112+
113+
repository = repositoryName
114+
commitish = "master"
115+
tagName = "v${project.version}"
116+
117+
if (project != rootProject) {
118+
parent(rootProject.tasks.named("publishGithub"))
119+
}
120+
}
121+
modrinth {
122+
accessToken = providers.environmentVariable("MODRINTH_API_TOKEN")
123+
.orElse(providers.gradleProperty("ccModrinthToken"))
124+
125+
version = "${project.version}"
126+
displayName = "${rootProject.name} v${project.version}"
127+
modLoaders.add("paper")
128+
129+
projectId = "xA2xhZUF"
130+
minecraftVersionRange {
131+
start = rootProject.libs.versions.paper.get().split("-")[0]
132+
end = "latest"
133+
}
134+
135+
requires("commandapi", "cloudcore")
136+
// even though luckperms doesn't publish paper jars on modrinth, add it as optional
137+
optional("launchplates", "luckperms")
138+
}
139+
}
140+
141+
tasks.withType<PublishModTask> {
142+
dependsOn(tasks.named<Jar>("shadowJar"))
143+
dependsOn(tasks.named<Jar>("sourcesJar"))
144+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=1.10.4

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pluginyml = "0.6.0"
33
runtask = "2.3.1"
44
shadow = "8.3.0"
5+
publishing = "0.7.4"
56

67
paper = "1.21.1-R0.1-SNAPSHOT"
78
luckperms-api = "5.4"
@@ -19,6 +20,7 @@ debuggery = "1.5.1"
1920
pluginyml-bukkit = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" }
2021
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "runtask" }
2122
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
23+
publishing = { id = "me.modmuss50.mod-publish-plugin", version.ref = "publishing" }
2224

2325
[libraries]
2426
paper-api = { module = "io.papermc.paper:paper-api", version.ref = "paper" }

0 commit comments

Comments
 (0)