Skip to content

Commit

Permalink
chore: publish on maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Nov 30, 2023
1 parent dae7bb8 commit dd3a30d
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Gradle Publish to Maven Central

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
runs-on: ubuntu-latest
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Publish to Sonatype
env:
TAG_VERSION: ${{ github.ref_name }}
run: |
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
echo "Version: ${TAG_VERSION}" >> $GITHUB_STEP_SUMMARY
87 changes: 85 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
plugins {
`java-library`

`maven-publish`
signing
alias(libs.plugins.nexuspublish)
}

group = "net.hollowcube"
version = "1.0-SNAPSHOT"
group = "dev.hollowcube"
version = System.getenv("TAG_VERSION") ?: "dev"
description = "Schematic reader and writer for Minestom"

repositories {
mavenCentral()
Expand All @@ -19,6 +24,84 @@ dependencies {
testImplementation(libs.bundles.logback)
}

java {
withSourcesJar()
withJavadocJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.test {
useJUnitPlatform()
}

nexusPublishing {
this.packageGroup.set("dev.hollowcube")

repositories.sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))

if (System.getenv("SONATYPE_USERNAME") != null) {
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}

publishing.publications.create<MavenPublication>("maven") {
groupId = "dev.hollowcube"
artifactId = "schem"
version = project.version.toString()

from(project.components["java"])

pom {
name.set(artifactId)
description.set(project.description)
url.set("https://github.com/hollow-cube/schem")

licenses {
license {
name.set("MIT")
url.set("https://github.com/hollow-cube/schem/blob/main/LICENSE")
}
}

developers {
developer {
id.set("mworzala")
name.set("Matt Worzala")
email.set("[email protected]")
}
}

issueManagement {
system.set("GitHub")
url.set("https://github.com/hollow-cube/schem/issues")
}

scm {
connection.set("scm:git:git://github.com/hollow-cube/schem.git")
developerConnection.set("scm:git:[email protected]:hollow-cube/schem.git")
url.set("https://github.com/hollow-cube/schem")
tag.set(System.getenv("TAG_VERSION") ?: "HEAD")
}

ciManagement {
system.set("Github Actions")
url.set("https://github.com/hollow-cube/schem/actions")
}
}
}

signing {
isRequired = System.getenv("CI") != null

val privateKey = System.getenv("GPG_PRIVATE_KEY")
val keyPassphrase = System.getenv()["GPG_PASSPHRASE"]
useInMemoryPgpKeys(privateKey, keyPassphrase)

sign(publishing.publications)
}
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata.format.version = "1.1"
minestom = "8715f4305d"
logback = "1.4.5" # For tests only

nexuspublish = "1.3.0"

[libraries]
minestom = { group = "dev.hollowcube", name = "minestom-ce", version.ref = "minestom" }

Expand All @@ -12,3 +14,6 @@ logback-classic = { group = "ch.qos.logback", name = "logback-classic", version.

[bundles]
logback = ["logback-core", "logback-classic"]

[plugins]
nexuspublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexuspublish" }

0 comments on commit dd3a30d

Please sign in to comment.