Skip to content

Commit

Permalink
Merge pull request #41 from morinoparty/develop
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
Nlkomaru authored May 20, 2024
2 parents d30233a + 87985e0 commit 55c1646
Show file tree
Hide file tree
Showing 62 changed files with 166 additions and 47 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/check_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
context: Check pull request

- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'gradle'

- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew build -x test

- name: Set final commit status
uses: myrotvorets/set-commit-status-action@master
if: always()
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@ jobs:
pip install mkdocs-static-i18n[material]
pip install mkdocs-render-swagger-plugin
- run: git pull
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'

- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew :api:dokkaHtml

- name: Copy dokkaHtml to docs
run: cp -r ./api/build/dokka/html ./docs/docs/dokka

- run: mkdocs gh-deploy --config-file ./docs/mkdocs.yml
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'gradle'

- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew build -x test

- uses: release-drafter/release-drafter@v5
id: release-drafter
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'gradle'

- name: Change wrapper permissions
Expand All @@ -27,16 +27,16 @@ jobs:
sed -i -e "s/minecraft_plugin_version/$after/i" './gradle.properties'
- name: Build with Gradle
run: ./gradlew build -x test
run: ./gradlew :core:build -x test

- name: Upload release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./mineauth-core/build/libs/MineAuth-${{ github.event.release.tag_name }}.jar
asset_name: MineAuth_${{ github.event.release.tag_name }}.jar
asset_path: ./core/build/libs/core-${{ github.event.release.tag_name }}.jar
asset_name: MineAuth-core_${{ github.event.release.tag_name }}.jar
asset_content_type: application/jar


28 changes: 28 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
alias(libs.plugins.kotlin.jvm)
}

dependencies {
compileOnly(libs.paper.api)
implementation(kotlin("stdlib-jdk8"))
}

group = project.group
version = project.version.toString()

kotlin {
jvmToolchain {
(this).languageVersion.set(JavaLanguageVersion.of(21))
}
jvmToolchain(21)
}

tasks {
compileKotlin {
kotlinOptions.jvmTarget = "21"
kotlinOptions.javaParameters = true
}
}
repositories {
mavenCentral()
}
7 changes: 7 additions & 0 deletions api/src/main/kotlin/party/morino/mineauth/api/MineAuthAPI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package party.morino.mineauth.api

import org.bukkit.plugin.java.JavaPlugin

interface MineAuthAPI {
abstract fun createHandler(plugin : JavaPlugin): RegisterHandler
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package party.morino.mineauth.api


interface RegisterHandler {
fun register(vararg endpoints: Any): RegisterHandler

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package party.morino.mineauth.api.annotations

@Target(AnnotationTarget.VALUE_PARAMETER)
annotation class Parms(
val value: Array<String>
)
5 changes: 1 addition & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins {
java
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.dokka)
}

val projectVersion: String by project
Expand All @@ -13,10 +14,6 @@ buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.5.31")
}
}

subprojects {
Expand Down
9 changes: 6 additions & 3 deletions mineauth-core/build.gradle.kts → core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ repositories {
maven("https://repo.codemc.io/repository/maven-public/")
}

group = "party.morino"
version = "1.0-SNAPSHOT"
group = project.group
version = project.version.toString()

dependencies {
implementation(project(":mineauth-api"))
implementation(project(":api"))
compileOnly(libs.paper.api)

implementation(libs.bundles.commands)
Expand All @@ -39,12 +39,14 @@ dependencies {
implementation(libs.bundles.exposed)

implementation(libs.koin.core)
implementation(kotlin("stdlib-jdk8"))
}

kotlin {
jvmToolchain {
(this).languageVersion.set(JavaLanguageVersion.of(17))
}
jvmToolchain(17)
}

tasks {
Expand Down Expand Up @@ -77,6 +79,7 @@ sourceSets.main {
main = "$group.mineauth.core.MineAuth"
apiVersion = "1.20"
libraries = libs.bundles.coroutines.asString()
softDepend = listOf("Vault")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package party.morino.mineauth.core

import com.github.shynixn.mccoroutine.bukkit.SuspendingJavaPlugin
import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin
import org.koin.core.context.GlobalContext
import org.koin.dsl.module
import party.morino.mineauth.api.MineAuthAPI
import party.morino.mineauth.api.RegisterHandler
import party.morino.mineauth.core.commands.HelpCommand
import party.morino.mineauth.core.commands.RegisterCommand
import party.morino.mineauth.core.commands.ReloadCommand
Expand Down Expand Up @@ -66,5 +68,8 @@ open class MineAuth: SuspendingJavaPlugin() , MineAuthAPI {
}
}

override fun createHandler(plugin: JavaPlugin): RegisterHandler {
TODO("Not yet implemented")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ object WebServer: KoinComponent {

private fun Application.module() {
val plugin: MineAuth by inject(MineAuth::class.java)
val webServerConfigData: WebServerConfigData = get(WebServerConfigData::class.java)
val jwtConfigData: JWTConfigData = get(JWTConfigData::class.java)
install(ContentNegotiation) {
json()
Expand Down Expand Up @@ -110,6 +109,14 @@ private fun Application.module() {
call.respondText("Hello World!")
}
}
route("/list") {
get {
val list = getRoutes(this@routing).map { it.toString() }
call.respond(
list
)
}
}
staticFiles("assets", plugin.dataFolder.resolve("assets"))

authRouter()
Expand All @@ -134,3 +141,12 @@ private fun Application.module() {
} // openAPI(path = "openapi", swaggerFile = "openapi/documentation.yaml") {}
}
}

private fun getRoutes(route: Route): List<Route> {
val list = mutableListOf<Route>()
route.children.forEach {
list.addAll(getRoutes(it))
}
list.add(route)
return list
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package party.morino.mineauth.core.web.router.plugin
import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import party.morino.mineauth.core.web.router.plugin.vault.VaultRouter.vaultRouter

object PluginRouter {
fun Route.pluginRouter() {
route("/plugin") {
get {
call.respondText("Hello, plugin!")
}
get {
call.respondText("Hello, plugin!")
}
vaultRouter()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package party.morino.mineauth.core.web.router.plugin.vault

import io.ktor.server.routing.*

object VaultRouter {
fun Route.vaultRouter() {
route("/vault") {
get {
this@route
}
}
}
}
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,28 @@ security:
- oauth2: [ read.*, write.* ]

paths:
/oauth2/userinfo:
- /oauth2/userinfo:
get:
summary: Get user information
security:
- oauth2: [ read ]
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
id:
type: string
description: The user UUID
username:
type: string
description: The user name
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
File renamed without changes.
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mineauth-docs.morino.party
16 changes: 16 additions & 0 deletions docs/docs/assets/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ paths:
summary: Get user information
security:
- oauth2: [ profile ]
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
id:
type: string
example: "069a79f4-44e9-4726-a5be-fca90e38aaf5"
description: The user UUID
username:
type: string
example: "Notch"
description: The user name
/oauth2/revoke:
post:
summary: Revoke access token
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
xyz.jpenilla.run-paper.updateCheckFrequency=12h
projectVersion=1.0-SNAPSHOT

sourceCompatibility = 17
targetCompatibility = 17
# Gradle Properties
org.gradle.caching=true
org.gradle.parallel=true
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koinV
run-paper = { id = "xyz.jpenilla.run-paper", version = "2.2.3" }
resource-factory = { id = "xyz.jpenilla.resource-factory", version = "1.1.1" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.23" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.24" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version = "1.9.23" }
dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }

Expand Down
17 changes: 0 additions & 17 deletions mineauth-api/build.gradle.kts

This file was deleted.

This file was deleted.

Loading

0 comments on commit 55c1646

Please sign in to comment.