Skip to content

Commit

Permalink
update release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Jun 5, 2024
1 parent 9b7b4fc commit c55b22d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/scripts/get-release-targets.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import com.google.gson.Gson
import org.kohsuke.github.GitHubBuilder
import java.io.File
import kotlin.reflect.full.memberProperties

val script = this

class Environment {
val github = Github()
Expand Down Expand Up @@ -130,14 +127,12 @@ env.github.workspace.resolve("CHANGELOG.txt").reader().forEachLine l@{ line ->
}
}

class Output {
val empty = script.branches.isEmpty().toString()
val branches = script.branches.keys.sorted().joinToString(separator = "\", \"", prefix = "[\"", postfix = "\"]") { script.branches[it]!! }
val changelogs = Gson().toJson(script.changelogs)!!
}

val output = Output()
val output = mapOf(
"empty" to branches.isEmpty().toString(),
"branches" to branches.keys.sorted().joinToString(separator = "\", \"", prefix = "[\"", postfix = "\"]") { branches[it]!! },
"changelogs" to Gson().toJson(changelogs),
)

Output::class.memberProperties.forEach { property ->
env.github.output.appendText("${property.name}=${property.get(output)}\n")
output.forEach { (key, value) ->
env.github.output.appendText("${key}=${value}\n")
}
27 changes: 11 additions & 16 deletions .github/workflows/scripts/parse-changelog.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.io.File
import kotlin.reflect.full.memberProperties

val script = this

class Environment {
val githubOutput = File(System.getenv("GITHUB_OUTPUT"))
Expand All @@ -26,18 +23,16 @@ class Changelog(
val env = Environment()
val changelog = env.changelogs[env.branch]!!

class Output {
val version = script.changelog.version
val java = script.changelog.java
val minecraft = script.changelog.minecraft
val prerelease = env.branch == "dev/snapshot"
val changelog = Gson().toJson(
"${script.changelog.changelog}\n_Full changelog can be seen at <https://raw.githubusercontent.com/badasintended/wthit/dev/master/CHANGELOG.txt>_"
)!!
}

val output = Output()
val output = mapOf(
"version" to changelog.version,
"java" to changelog.java,
"minecraft" to changelog.minecraft,
"prerelease" to (env.branch == "dev/snapshot"),
"changelog" to Gson().toJson(
"${changelog.changelog}\n_Full changelog can be seen at <https://raw.githubusercontent.com/badasintended/wthit/dev/master/CHANGELOG.txt>_"
)
)

Output::class.memberProperties.forEach { property ->
env.githubOutput.appendText("${property.name}=${property.get(output)}\n")
output.forEach { (key, value) ->
env.githubOutput.appendText("${key}=${value}\n")
}

0 comments on commit c55b22d

Please sign in to comment.