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 - name: Run build & publish with Gradle Wrapper
if: github.ref == 'refs/heads/master' 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 run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository
- name: Run build with Gradle Wrapper - 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 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) 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.
The examples below use my repository, open the jitpack link for its group information.
Gradle (Groovy DSL): Gradle (Groovy DSL):
```groovy ```groovy
repositories { repositories {
maven { url 'https://maven.evokegames.gg/snapshots' } mavenCentral()
} }
dependencies { dependencies {
implementation 'me.tofaa.entitylib:<platform>:<latest-release-version' implementation 'io.github.tofaa2:<platform>:<version>'
} }
``` ```
Gradle (Kotlin DSL): Gradle (Kotlin DSL):
```kotlin ```kotlin
repositories { repositories {
maven(url = "https://maven.evokegames.gg/snapshots") mavenCentral()
} }
dependencies { dependencies {
implementation("me.tofaa.entitylib:<platform>:<latest-release-version>") implementation("io.github.tofaa2:<platform>:<version>")
} }
``` ```
Maven: Maven:
```xml ```xml
<dependency> <dependency>
<groupId>me.tofaa.entitylib</groupId> <groupId>io.github.tofaa2</groupId>
<artifactId>(platform)</artifactId> <artifactId><platform></artifactId>
<version>(latest-release-version)</version> <version><version></version>
</dependency> </dependency>
``` ```

View file

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

View file

@ -1,6 +1,7 @@
plugins { plugins {
`java-library` `java-library`
`maven-publish` `maven-publish`
signing
} }
group = rootProject.group group = rootProject.group
@ -45,17 +46,6 @@ tasks {
} }
publishing { publishing {
repositories {
maven {
url = uri("https://maven.evokegames.gg/snapshots")
credentials {
username = System.getenv("TYCOONS_REPO_USER")
password = System.getenv("TYCOONS_REPO_PASS")
}
}
}
publications { publications {
create<MavenPublication>("EntityLib") { create<MavenPublication>("EntityLib") {
groupId = project.group as String groupId = project.group as String
@ -75,6 +65,14 @@ publishing {
} }
} }
developers {
developer {
id = "Tofaa2"
name = "Tofaa"
email = "tofaadev@gmail.com"
}
}
scm { scm {
connection = "scm:git:https://github.com/Tofaa2/EntityLib.git" connection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
developerConnection = "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 // So that SNAPSHOT is always the latest SNAPSHOT