Skip to content

Commit

Permalink
chore: Add publish task
Browse files Browse the repository at this point in the history
  • Loading branch information
sya-ri committed Apr 13, 2024
1 parent 3c4ca80 commit 5e7eb9c
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 7 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Build
run: ./gradlew build
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish
on:
workflow_dispatch:

env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: gradle
- name: Publish
run: |
./gradlew publish --no-daemon --stacktrace
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![Compatible with CommandAPI v9.3.0](https://img.shields.io/badge/Compatible%20with-CommandAPI%20v9.3.0-brightgreen)](https://commandapi.jorel.dev/9.3.0/)

Improve CommandAPI Kotlin DSL.

- A better alternative library to [official Kotlin DSL](https://commandapi.jorel.dev/9.3.0/kotlindsl.html)
- shorter, more type-safe code
- Code compatibility. Change the import, and it will work (but doesn't support CommandAPICommand)
Expand Down
73 changes: 73 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
plugins {
`maven-publish`
signing
}

subprojects {
apply(plugin = "maven-publish")
apply(plugin = "signing")

version = "1.0.0-SNAPSHOT"

val sourceJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}

publishing {
repositories {
maven {
url =
uri(
if (version.toString().endsWith("SNAPSHOT")) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
},
)
credentials {
username = properties["sonatypeUsername"].toString()
password = properties["sonatypePassword"].toString()
}
}
}
publications {
register<MavenPublication>("maven") {
groupId = "dev.s7a"
artifactId = "commandapi-${project.name}-kotlin-improved"
from(components["kotlin"])
artifact(sourceJar.get())
pom {
name.set("commandapi-${project.name}-kotlin-improved")
description.set("Improve CommandAPI Kotlin DSL")
url.set("https://github.com/sya-ri/commandapi-kotlin-improved")

licenses {
license {
name.set("MIT License")
url.set("https://github.com/sya-ri/commandapi-kotlin-improved/blob/master/LICENSE")
}
}
developers {
developer {
id.set("sya-ri")
name.set("sya-ri")
email.set("contact@s7a.dev")
}
}
scm {
url.set("https://github.com/sya-ri/commandapi-kotlin-improved")
}
}
}
}
}

signing {
val key = properties["signingKey"]?.toString()?.replace("\\n", "\n")
val password = properties["signingPassword"]?.toString()

useInMemoryPgpKeys(key, password)
sign(publishing.publications["maven"])
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
val gitVersion: Closure<String> by extra

group = "dev.s7a"
version = "1.0-SNAPSHOT"
version = gitVersion()

allprojects {
repositories {
Expand Down
5 changes: 1 addition & 4 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import dev.s7a.gradle.minecraft.server.tasks.LaunchMinecraftServerTask
import dev.s7a.gradle.minecraft.server.tasks.LaunchMinecraftServerTask.JarUrl
import groovy.lang.Closure
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription

plugins {
Expand All @@ -16,15 +15,13 @@ subprojects {
apply(plugin = libs.plugins.plugin.yml.bukkit.get().pluginId)
apply(plugin = libs.plugins.minecraft.server.get().pluginId)

val gitVersion: Closure<String> by extra

dependencies {
compileOnly(libs.paper.api)
}

configure<BukkitPluginDescription> {
main = "dev.s7a.commandapi.example.ExamplePlugin"
version = gitVersion()
version = rootProject.version.toString()
apiVersion = "1.16"
author = "sya_ri"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/improved/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies {
implementation(libs.commandapi.bukkit.shade)
implementation(project(":bukkit"))
implementation(project(":api:bukkit"))
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rootProject.name = "commandapi-kotlin-improved"

include(
":bukkit",
":api:bukkit",
":examples:original",
":examples:improved",
)

0 comments on commit 5e7eb9c

Please # to comment.