Skip to content

Commit

Permalink
Fix version when releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Jan 29, 2021
1 parent b262c63 commit e4a2ea0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/2-release-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ jobs:
registry: docker.pkg.github.com
repository: dunctebot/skybot/skybot
tags: latest
build_args: is_ci=true,git_sha=${{ github.sha }}
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
FROM adoptopenjdk:15-jdk-hotspot AS builder

WORKDIR /skybot

# setup CI flag
ARG is_ci
ARG git_sha
ENV CI=$is_ci
ENV GIT_HASH=$git_sha

COPY gradle ./gradle
COPY gradlew build.gradle.kts settings.gradle.kts ./
RUN ./gradlew --no-daemon dependencies
Expand Down
10 changes: 6 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ plugins {
pmd
}

val numberVersion = "3.101.0"
val numberVersion = "3.101.1"

project.group = "ml.duncte123.skybot"
project.version = "${numberVersion}_${getGitHash()}"
Expand Down Expand Up @@ -93,7 +93,7 @@ dependencies {
implementation(group = "me.duncte123", name = "botCommons", version = "2.0.122")

// JDA (java discord api)
implementation(group = "net.dv8tion", name = "JDA", version = "4.2.0_224") {
implementation(group = "net.dv8tion", name = "JDA", version = "4.2.0_227") {
exclude(module = "opus-java")
}

Expand Down Expand Up @@ -327,8 +327,10 @@ fun getGitHash(): String {

stdout.toString().trim()
} catch (ignored: Throwable) {
// Probably ramidzkh"s problem
"DEV"
// Ugly hacks 101 :D
val hash = System.getenv("GIT_HASH") ?: "dev"

return hash.substring(0, Math.min(8, hash.length))
}
}

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ services:
container_name: skybot
build:
context: .
args:
- is_ci=true
- git_sha=DEV
environment:
# Bot settings
- BOT_ADMINS=191231307290771456,311769499995209728
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package ml.duncte123.skybot.commands.essentials.eval

import com.github.natanbc.reliqua.request.PendingRequest
import groovy.lang.GroovyShell
import kotlinx.coroutines.*
import me.duncte123.botcommons.StringUtils
import me.duncte123.botcommons.messaging.MessageUtils.*
Expand All @@ -39,6 +38,8 @@ import ml.duncte123.skybot.utils.JSONMessageErrorsHelper.sendErrorJSON
import net.dv8tion.jda.api.requests.RestAction
import java.io.PrintWriter
import java.io.StringWriter
import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
import kotlin.system.measureTimeMillis

@Authors(
Expand All @@ -49,7 +50,7 @@ import kotlin.system.measureTimeMillis
]
)
class EvalCommand : Command() {
private val engine: GroovyShell
private val engine: ScriptEngine by lazy { ScriptEngineManager().getEngineByName("groovy") }
private val importString: String

init {
Expand All @@ -59,8 +60,6 @@ class EvalCommand : Command() {
this.help = "Evaluate groovy/java code on the bot"
this.usage = "<java/groovy code>"

engine = GroovyShell()

val packageImports = listOf(
"java.io",
"java.lang",
Expand Down Expand Up @@ -121,19 +120,19 @@ class EvalCommand : Command() {

val script = importString + userIn

engine.setVariable("commandManager", ctx.commandManager)
engine.setVariable("message", ctx.message)
engine.setVariable("channel", ctx.message.textChannel)
engine.setVariable("guild", ctx.guild)
engine.setVariable("member", ctx.member)
engine.setVariable("author", ctx.author)
engine.setVariable("jda", ctx.jda)
engine.setVariable("shardManager", ctx.jda.shardManager)
engine.setVariable("event", ctx.event)
engine.put("commandManager", ctx.commandManager)
engine.put("message", ctx.message)
engine.put("channel", ctx.message.textChannel)
engine.put("guild", ctx.guild)
engine.put("member", ctx.member)
engine.put("author", ctx.author)
engine.put("jda", ctx.jda)
engine.put("shardManager", ctx.jda.shardManager)
engine.put("event", ctx.event)

engine.setVariable("args", ctx.args)
engine.setVariable("ctx", ctx)
engine.setVariable("variables", ctx.variables)
engine.put("args", ctx.args)
engine.put("ctx", ctx)
engine.put("variables", ctx.variables)

@SinceSkybot("3.58.0")
GlobalScope.launch(
Expand All @@ -149,7 +148,7 @@ class EvalCommand : Command() {
val time = measureTimeMillis {
val out = withTimeoutOrNull(60000L /* = 60 seconds */) {
try {
engine.evaluate(script)
engine.eval(script)
} catch (ex: Throwable) {
ex
}
Expand Down

0 comments on commit e4a2ea0

Please sign in to comment.