Attempt at central publishing

This commit is contained in:
Tofaa2 2025-10-25 17:37:40 +04:00
parent cef23ea82d
commit e85017fded
5 changed files with 81 additions and 22 deletions

View file

@ -32,6 +32,9 @@ jobs:
- name: Run build & publish with Gradle Wrapper
if: github.ref == 'refs/heads/master'
env:
OSSRH_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.CENTRAL_PORTAL_TOKEN }}
run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository
- name: Run build with Gradle Wrapper

View file

@ -0,0 +1,37 @@
name: Publish to Maven Central
on:
release:
types: [published]
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4
- name: Install JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
check-latest: true
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Import GPG key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --batch --yes
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --import
- name: Publish to Maven Central
env:
OSSRH_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.CENTRAL_PORTAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew publishAllPublicationsToMavenRepository --no-daemon

View file

@ -8,37 +8,36 @@ You can easily use EntityLib platformless by using the `api` or `common` module
If you like EntityLib and or want to sponsor me, visit my [ko-fi page](https://ko-fi.com/tofaa) :D
EntityLib builds are available on [Jitpack](https://jitpack.io/#Tofaa2/EntityLib) and my own [Maven Repository](https://maven.evokegames.gg/#/snapshots/me/tofaa/entitylib)
The examples below use my repository, open the jitpack link for its group information.
EntityLib is published to [Maven Central](https://central.sonatype.com/artifact/io.github.tofaa2). Snapshots are available on pushes to the main branch, and stable releases are published on GitHub releases.
Gradle (Groovy DSL):
```groovy
repositories {
maven { url 'https://maven.evokegames.gg/snapshots' }
mavenCentral()
}
dependencies {
implementation 'me.tofaa.entitylib:<platform>:<latest-release-version'
implementation 'io.github.tofaa2:<platform>:<version>'
}
```
Gradle (Kotlin DSL):
```kotlin
repositories {
maven(url = "https://maven.evokegames.gg/snapshots")
mavenCentral()
}
dependencies {
implementation("me.tofaa.entitylib:<platform>:<latest-release-version>")
implementation("io.github.tofaa2:<platform>:<version>")
}
```
Maven:
```xml
```xml
<dependency>
<groupId>me.tofaa.entitylib</groupId>
<artifactId>(platform)</artifactId>
<version>(latest-release-version)</version>
<groupId>io.github.tofaa2</groupId>
<artifactId><platform></artifactId>
<version><version></version>
</dependency>
```

View file

@ -3,7 +3,7 @@ import java.io.ByteArrayOutputStream
val fullVersion = "3.0.3"
val snapshot = true
group = "me.tofaa.entitylib"
group = "io.github.tofaa2"
description = rootProject.name
fun getVersionMeta(includeHash: Boolean): String {
@ -62,6 +62,12 @@ tasks {
}
}
register("publishAllPublicationsToMavenRepository") {
val publishTasks = subModuleTasks("publishAllPublicationsToMavenRepository")
dependsOn(publishTasks)
group = "publishing"
}
register<Delete>("clean") {
val cleanTasks = subModuleTasks("clean")
dependsOn(cleanTasks)

View file

@ -1,6 +1,7 @@
plugins {
`java-library`
`maven-publish`
signing
}
group = rootProject.group
@ -45,17 +46,6 @@ tasks {
}
publishing {
repositories {
maven {
url = uri("https://maven.evokegames.gg/snapshots")
credentials {
username = System.getenv("TYCOONS_REPO_USER")
password = System.getenv("TYCOONS_REPO_PASS")
}
}
}
publications {
create<MavenPublication>("EntityLib") {
groupId = project.group as String
@ -75,6 +65,14 @@ publishing {
}
}
developers {
developer {
id = "Tofaa2"
name = "Tofaa"
email = "tofaadev@gmail.com"
}
}
scm {
connection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
developerConnection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
@ -83,6 +81,22 @@ publishing {
}
}
}
repositories {
maven {
url = uri("https://central.sonatype.com/api/v1/publisher/upload")
credentials {
username = System.getenv("CENTRAL_PORTAL_USERNAME")
password = System.getenv("CENTRAL_PORTAL_TOKEN")
}
}
}
}
signing {
if (!version.toString().endsWith("-SNAPSHOT")) {
sign(publishing.publications["EntityLib"])
}
}
// So that SNAPSHOT is always the latest SNAPSHOT