Skip to content

Commit 6a96f14

Browse files
committed
Fix publication
1 parent caa59c6 commit 6a96f14

File tree

4 files changed

+134
-60
lines changed

4 files changed

+134
-60
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to Maven Central Snapshots
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
7+
env:
8+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
9+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
10+
SIGNING_KEY: ${{ secrets.PGP_KEY }}
11+
SIGNING_PASSWORD: ${{ secrets.PGP_PASSWORD }}
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4.2.2
22+
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v4.6.0
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
29+
- name: Publish snapshot to Maven Central
30+
run: ./gradlew publishAggregationToCentralPortalSnapshots
31+
32+
- name: Breakpoint if publish failed
33+
if: failure()
34+
uses: namespacelabs/breakpoint-action@v0
35+
with:
36+
duration: 30m
37+
authorized-users: Seggan
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags: [ '*' ]
6+
7+
env:
8+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
9+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
10+
SIGNING_KEY: ${{ secrets.PGP_KEY }}
11+
SIGNING_PASSWORD: ${{ secrets.PGP_PASSWORD }}
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4.2.2
22+
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v4.6.0
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
29+
- name: Publish to Maven Central
30+
run: ./gradlew publishAggregationToCentralPortal -Pversion=${{ github.ref_name }}
31+
32+
- name: Breakpoint if publish failed
33+
if: failure()
34+
uses: namespacelabs/breakpoint-action@v0
35+
with:
36+
duration: 30m
37+
authorized-users: Seggan

.github/workflows/release.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,4 @@ jobs:
2828
prerelease: false
2929
automatic_release_tag: ${{ github.ref_name }}
3030
title: Release ${{ github.ref_name }}
31-
files: pylon-base-*.jar
32-
33-
publish:
34-
needs: [build]
35-
runs-on: ubuntu-latest
36-
permissions:
37-
contents: read
38-
39-
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v4.2.2
42-
43-
- name: Set up JDK 21
44-
uses: actions/setup-java@v4.6.0
45-
with:
46-
java-version: '21'
47-
distribution: 'temurin'
48-
49-
- name: Setup Gradle
50-
uses: gradle/actions/setup-gradle@v4.2.2
51-
52-
- name: Publish snapshot
53-
run: ./gradlew :publishToCentralPortal -Pversion=${{ github.ref_name }}
54-
env:
55-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
56-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
57-
SIGNING_KEY: ${{ secrets.PGP_KEY }}
58-
SIGNING_PASSWORD: ${{ secrets.PGP_PASSWORD }}
31+
files: pylon-base-*.jar

build.gradle.kts

Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
22

33
plugins {
44
java
5+
`java-library`
56
idea
67
id("com.gradleup.shadow") version "8.3.2"
78
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
89
id("xyz.jpenilla.run-paper") version "2.3.0"
910
id("io.freefair.lombok") version "8.13.1"
1011
`maven-publish`
1112
signing
12-
id("net.thebugmc.gradle.sonatype-central-portal-publisher") version "1.2.4"
13+
id("com.gradleup.nmcp.aggregation") version "1.1.0"
1314
}
1415

1516
group = "io.github.pylonmc"
@@ -38,6 +39,8 @@ idea {
3839

3940
java {
4041
toolchain.languageVersion = JavaLanguageVersion.of(21)
42+
withSourcesJar()
43+
withJavadocJar()
4144
}
4245

4346
tasks.shadowJar {
@@ -68,44 +71,68 @@ tasks.runServer {
6871
minecraftVersion("1.21.8")
6972
}
7073

71-
// Disable signing for maven local publish
72-
if (project.gradle.startParameter.taskNames.any { it.contains("publishToMavenLocal") }) {
73-
tasks.withType<Sign>().configureEach {
74-
enabled = false
75-
}
76-
}
77-
7874
tasks.withType<Jar> {
7975
duplicatesStrategy = DuplicatesStrategy.INCLUDE
8076
}
8177

78+
publishing {
79+
publications {
80+
create<MavenPublication>("maven") {
81+
artifactId = project.name
82+
83+
from(components["java"])
84+
85+
pom {
86+
name = project.name
87+
description = "The base addon for Pylon."
88+
url = "https://github.com/pylonmc/pylon-base"
89+
licenses {
90+
license {
91+
name = "GNU Lesser General Public License Version 3"
92+
url = "https://www.gnu.org/licenses/lgpl-3.0.txt"
93+
}
94+
}
95+
developers {
96+
developer {
97+
id = "PylonMC"
98+
name = "PylonMC"
99+
organizationUrl = "https://github.com/pylonmc"
100+
}
101+
}
102+
scm {
103+
connection = "scm:git:git://github.com/pylonmc/pylon-base.git"
104+
developerConnection = "scm:git:ssh://github.com:pylonmc/pylon-base.git"
105+
url = "https://github.com/pylonmc/pylon-base"
106+
}
107+
// Bypass maven-publish erroring when using `from(components["java"])`
108+
withXml {
109+
val root = asNode()
110+
val dependenciesNode = root.appendNode("dependencies")
111+
val configs = listOf(configurations.compileOnlyApi, configurations.api)
112+
configs.flatMap { it.get().dependencies }.forEach {
113+
val dependencyNode = dependenciesNode.appendNode("dependency")
114+
dependencyNode.appendNode("groupId", it.group)
115+
dependencyNode.appendNode("artifactId", it.name)
116+
dependencyNode.appendNode("version", it.version)
117+
dependencyNode.appendNode("scope", "compile")
118+
}
119+
}
120+
}
121+
}
122+
}
123+
}
124+
82125
signing {
83126
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
127+
128+
sign(publishing.publications["maven"])
84129
}
85130

86-
centralPortal {
87-
username = System.getenv("SONATYPE_USERNAME")
88-
password = System.getenv("SONATYPE_PASSWORD")
89-
pom {
90-
description = "The base addon for Pylon."
91-
url = "https://github.com/pylonmc/pylon-base"
92-
licenses {
93-
license {
94-
name = "GNU Lesser General Public License Version 3"
95-
url = "https://www.gnu.org/licenses/lgpl-3.0.txt"
96-
}
97-
}
98-
developers {
99-
developer {
100-
id = "PylonMC"
101-
name = "PylonMC"
102-
organizationUrl = "https://github.com/pylonmc"
103-
}
104-
}
105-
scm {
106-
connection = "scm:git:git://github.com/pylonmc/pylon-base.git"
107-
developerConnection = "scm:git:ssh://github.com:pylonmc/pylon-base.git"
108-
url = "https://github.com/pylonmc/pylon-base"
109-
}
131+
nmcpAggregation {
132+
centralPortal {
133+
username = System.getenv("SONATYPE_USERNAME")
134+
password = System.getenv("SONATYPE_PASSWORD")
135+
publishingType = "AUTOMATIC"
110136
}
137+
publishAllProjectsProbablyBreakingProjectIsolation()
111138
}

0 commit comments

Comments
 (0)