Skip to content

Commit

Permalink
Update some action
Browse files Browse the repository at this point in the history
  • Loading branch information
Nlkomaru committed Dec 1, 2023
1 parent 450b6a1 commit 8e96ac8
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 75 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/build_and_deploy.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/check_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
context: Publish NPM package
context: Check pull request
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
Expand All @@ -26,10 +26,11 @@ jobs:
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build -x test
- name: Set final commit status
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: Check pull request
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release Drafter

on:
push:
branches:
- master

permissions:
contents: read

jobs:
build:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

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

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

- name: Test with Gradle
run: ./gradlew test

- name: Publish test results
id: publish-test-results
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'

- uses: release-drafter/release-drafter@v5
id: release-drafter
with:
publish: false
footer: |
## Check summary
<table>
<tr>
<th>
<th>Tests 💯</th>
<th>Passed ✅</th>
<th>Skipped ⏭️</th>
<th>Failed ❌</th>
</tr>
<tr>
<td>JUnit Test Report</td>
<td>${{ steps.publish-test-results.outputs.total }} ran</td>
<td>${{ steps.publish-test-results.outputs.passed }} passed</td>
<td>${{ steps.publish-test-results.outputs.skipped }} skipped</td>
<td>${{ steps.publish-test-results.outputs.failed }} failed</td>
</tr>
</table>
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: test

on: [pull_request]

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Test with Gradle
run: ./gradlew test
- name: Publish test results
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
36 changes: 36 additions & 0 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: upload_release

on:
release:
types: [ published ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

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

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

- name: Build with Gradle
run: ./gradlew 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: ./build/libs/PluginTemplate-1.0-SNAPSHOT-all.jar # TODO need to change
asset_name: PluginTemplate_${{ github.event.release.tag_name }}.jar # TODO need to change
asset_content_type: application/jar


63 changes: 43 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
id("java")
kotlin("jvm") version "1.9.20"
Expand All @@ -7,7 +9,7 @@ plugins {
kotlin("plugin.serialization") version "1.9.20"
}

group = "dev.nikomaru"
group = "dev.nikomaru" //TODO need to change
version = "1.0-SNAPSHOT"

fun captureVersion(dependency: Dependency): String {
Expand All @@ -28,22 +30,38 @@ repositories {


dependencies {
val paperVersion = captureVersion(implementation("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")!!)
val mccoroutineVersion = captureVersion(implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.13.0")!!)
val lampVersion = captureVersion(implementation("com.github.Revxrsal.Lamp:common:3.1.7")!!)
val paperVersion = "1.20.2-R0.1-SNAPSHOT"
val mccoroutineVersion = "2.13.0"
val lampVersion = "3.1.8"
val koinVersion = "3.5.0"
val coroutineVersion = "1.7.3"
val serializationVersion = "1.6.1"
val junitVersion = "5.10.1"
val mockkVersion = "1.13.8"
val mockBukkitVersion = "3.47.0"


compileOnly("io.papermc.paper", "paper-api", paperVersion)
compileOnly("io.papermc.paper:paper-api:$paperVersion")

library(kotlin("stdlib"))

implementation("com.github.Revxrsal.Lamp","common",lampVersion)
implementation("com.github.Revxrsal.Lamp","bukkit",lampVersion)
implementation("com.github.Revxrsal.Lamp:common:$lampVersion")
implementation("com.github.Revxrsal.Lamp:bukkit:$lampVersion")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")

implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.7.3")
implementation("org.jetbrains.kotlinx", "kotlinx-serialization-json", "1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")

library("com.github.shynixn.mccoroutine", "mccoroutine-bukkit-api", mccoroutineVersion)
library("com.github.shynixn.mccoroutine", "mccoroutine-bukkit-core", mccoroutineVersion)
library("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:$mccoroutineVersion")
library("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:$mccoroutineVersion")

implementation("io.insert-koin:koin-core:$koinVersion")

testImplementation("com.github.seeseemelk:MockBukkit-v1.20:$mockBukkitVersion")
testImplementation("io.mockk:mockk:$mockkVersion")
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testImplementation("io.insert-koin:koin-test:$koinVersion")
testImplementation("io.insert-koin:koin-test-junit5:$koinVersion")
}

java {
Expand All @@ -61,25 +79,30 @@ tasks {
build {
dependsOn(shadowJar)
}
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}

tasks {
runServer {
minecraftVersion("1.20.2")
}
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
test {
useJUnitPlatform()
testLogging {
showStandardStreams = true
events("passed", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
}
}
}



bukkit {
name = "Template" // need to change
name = "Template" //TODO need to change
version = "miencraft_plugin_version"
website = "https://github.com/Nlkomaru/NoticeTemplate" // need to change
website = "https://github.com/Nlkomaru/NoticeTemplate" //TODO need to change

main = "$group.template.Template" // need to change
main = "$group.template.Template" //TODO need to change

apiVersion = "1.20"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = "NoticeTemplate"
rootProject.name = "PluginTemplate" //TODO need to change

pluginManagement {
repositories {
Expand Down
20 changes: 16 additions & 4 deletions src/main/kotlin/dev/nikomaru/template/Template.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package dev.nikomaru.template

import dev.nikomaru.template.commands.HelpCommand
import org.bukkit.plugin.java.JavaPlugin
import org.koin.core.context.GlobalContext
import org.koin.dsl.module
import revxrsal.commands.bukkit.BukkitCommandHandler
import revxrsal.commands.ktx.supportSuspendFunctions

class Template : JavaPlugin() {
open class Template : JavaPlugin() {

companion object {
lateinit var plugin: Template
Expand All @@ -15,8 +17,18 @@ class Template : JavaPlugin() {
// Plugin startup logic
plugin = this
setCommand()
setupKoin()
}

private fun setupKoin() {
val appModule = module {
single<Template> { this@Template }
}

GlobalContext.getOrNull() ?: GlobalContext.startKoin {
modules(appModule)
}
}
override fun onDisable() {
// Plugin shutdown logic
}
Expand All @@ -31,9 +43,9 @@ class Template : JavaPlugin() {
handler.setHelpWriter { command, actor ->
java.lang.String.format(
"""
<color:yellow>コマンド: <color:gray>%s
<color:yellow>使用方法: <color:gray>%s
<color:yellow>説明: <color:gray>%s
<color:yellow>command: <color:gray>%s
<color:yellow>usage: <color:gray>%s
<color:yellow>description: <color:gray>%s
""".trimIndent(),
command.path.toList(),
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/dev/nikomaru/template/commands/HelpCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import org.bukkit.command.CommandSender
import revxrsal.commands.annotation.Command
import revxrsal.commands.annotation.Default
import revxrsal.commands.annotation.Description
import revxrsal.commands.annotation.Subcommand
import revxrsal.commands.help.CommandHelp

//TODO to use this command, the name of the command annotation must be replaced with the name of the plugin
//TODO replaced with the name of the plugin
@Command("plugin-template")
class HelpCommand {
@Command("help")
@Subcommand("help")
@Description("Shows the help menu")
fun help(sender: CommandSender, helpEntries: CommandHelp<String>, @Default("1") page: Int) {
for (entry in helpEntries.paginate(page, 7)) // 7 entries per page
Expand Down
Loading

0 comments on commit 8e96ac8

Please sign in to comment.