From 4ca7b6b11c0427a5e26a581a9980ebb526447477 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Mon, 10 Jul 2023 19:36:18 +0800 Subject: [PATCH] Show changelog for CI build --- .../hippo/ehviewer/ui/settings/AboutScreen.kt | 9 +++++++-- .../java/tachiyomi/data/release/GithubCommit.kt | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/tachiyomi/data/release/GithubCommit.kt diff --git a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt index fe78f1cf1..df9dbfffe 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt @@ -48,6 +48,7 @@ import okhttp3.Request import okio.sink import org.json.JSONObject import tachiyomi.data.release.GithubArtifacts +import tachiyomi.data.release.GithubCommitComparison import tachiyomi.data.release.GithubRelease import tachiyomi.data.release.GithubWorkflowRuns import java.io.File @@ -156,8 +157,12 @@ fun AboutScreen() { val artifacts = ghRequest(workflowRun.artifactsUrl).executeAndParseAs() if (artifacts.artifacts.isNotEmpty()) { val archiveUrl = artifacts.getDownloadLink() - // TODO: Show changelog - dialogState.showNewVersion(shortSha, workflowRun.title) { file -> + val changelog = runSuspendCatching { + val commitComparisonUrl = "$API_URL/compare/$curSha...$shortSha" + val result = ghRequest(commitComparisonUrl).executeAndParseAs() + result.commits.joinToString("\n") { "${it.commit.message} (@${it.author.name})" } + }.getOrDefault(workflowRun.title) + dialogState.showNewVersion(shortSha, changelog) { file -> ghRequest(archiveUrl).execute { ZipInputStream(body.byteStream()).use { zip -> zip.nextEntry diff --git a/app/src/main/java/tachiyomi/data/release/GithubCommit.kt b/app/src/main/java/tachiyomi/data/release/GithubCommit.kt new file mode 100644 index 000000000..49e40be8f --- /dev/null +++ b/app/src/main/java/tachiyomi/data/release/GithubCommit.kt @@ -0,0 +1,16 @@ +package tachiyomi.data.release + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class GithubCommitComparison(val commits: List) + +@Serializable +data class GithubCommit(val commit: GithubCommitDetail, val author: GithubCommitAuthor) + +@Serializable +data class GithubCommitDetail(val message: String) + +@Serializable +data class GithubCommitAuthor(@SerialName("login") val name: String)