mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 14:52:05 +01:00
bundle WebUI for stable builds
This commit is contained in:
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
build-root-directory: master
|
build-root-directory: master
|
||||||
wrapper-directory: master
|
wrapper-directory: master
|
||||||
arguments: :webUI:copyBuild :server:shadowJar --stacktrace
|
arguments: :server:downloadWebUI :server:shadowJar --stacktrace
|
||||||
wrapper-cache-enabled: true
|
wrapper-cache-enabled: true
|
||||||
dependencies-cache-enabled: true
|
dependencies-cache-enabled: true
|
||||||
configuration-cache-enabled: true
|
configuration-cache-enabled: true
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,7 +6,7 @@ gradle.properties
|
|||||||
# Ignore Gradle build output directory
|
# Ignore Gradle build output directory
|
||||||
build
|
build
|
||||||
|
|
||||||
server/src/main/resources/webUI
|
server/src/main/resources/WebUI.zip
|
||||||
server/tmp/
|
server/tmp/
|
||||||
server/tachiserver-data/
|
server/tachiserver-data/
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,12 @@ tasks {
|
|||||||
|
|
||||||
named<Copy>("processResources") {
|
named<Copy>("processResources") {
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
mustRunAfter("downloadWebUI")
|
||||||
|
}
|
||||||
|
|
||||||
|
register<de.undercouch.gradle.tasks.download.Download>("downloadWebUI") {
|
||||||
|
src("https://github.com/Suwayomi/Tachidesk-WebUI-preview/releases/download/$webUIRevisionTag/Tachidesk-WebUI-$webUIRevisionTag.zip")
|
||||||
|
dest("src/main/resources/WebUI.zip")
|
||||||
}
|
}
|
||||||
|
|
||||||
withType<LintTask> {
|
withType<LintTask> {
|
||||||
|
|||||||
@@ -53,40 +53,56 @@ fun setupWebUI() {
|
|||||||
} else {
|
} else {
|
||||||
File(applicationDirs.webUIRoot).deleteRecursively()
|
File(applicationDirs.webUIRoot).deleteRecursively()
|
||||||
|
|
||||||
// download webUI zip
|
|
||||||
val webUIZip = "Tachidesk-WebUI-${BuildConfig.WEBUI_TAG}.zip"
|
val webUIZip = "Tachidesk-WebUI-${BuildConfig.WEBUI_TAG}.zip"
|
||||||
val webUIZipPath = "$tmpDir/$webUIZip"
|
val webUIZipPath = "$tmpDir/$webUIZip"
|
||||||
val webUIZipURL = "${BuildConfig.WEBUI_REPO}/releases/download/${BuildConfig.WEBUI_TAG}/$webUIZip"
|
|
||||||
val webUIZipFile = File(webUIZipPath)
|
val webUIZipFile = File(webUIZipPath)
|
||||||
webUIZipFile.delete()
|
|
||||||
|
|
||||||
logger.info { "Downloading WebUI zip from the Internet..." }
|
// try with resources first
|
||||||
val data = ByteArray(1024)
|
val resourceWebUI = try {
|
||||||
|
BuildConfig::class.java.getResourceAsStream("/WebUI.zip")
|
||||||
|
} catch (e: NullPointerException) { null }
|
||||||
|
|
||||||
webUIZipFile.outputStream().use { webUIZipFileOut ->
|
if (resourceWebUI == null) { // is not bundled
|
||||||
BufferedInputStream(URL(webUIZipURL).openStream()).use { inp ->
|
// download webUI zip
|
||||||
var totalCount = 0
|
val webUIZipURL = "${BuildConfig.WEBUI_REPO}/releases/download/${BuildConfig.WEBUI_TAG}/$webUIZip"
|
||||||
var tresh = 0
|
webUIZipFile.delete()
|
||||||
while (true) {
|
|
||||||
val count = inp.read(data, 0, 1024)
|
logger.info { "Downloading WebUI zip from the Internet..." }
|
||||||
totalCount += count
|
val data = ByteArray(1024)
|
||||||
if (totalCount > tresh + 10 * 1024) {
|
|
||||||
tresh = totalCount
|
webUIZipFile.outputStream().use { webUIZipFileOut ->
|
||||||
print(" *")
|
BufferedInputStream(URL(webUIZipURL).openStream()).use { inp ->
|
||||||
|
var totalCount = 0
|
||||||
|
var tresh = 0
|
||||||
|
while (true) {
|
||||||
|
val count = inp.read(data, 0, 1024)
|
||||||
|
totalCount += count
|
||||||
|
if (totalCount > tresh + 10 * 1024) {
|
||||||
|
tresh = totalCount
|
||||||
|
print(" *")
|
||||||
|
}
|
||||||
|
if (count == -1)
|
||||||
|
break
|
||||||
|
webUIZipFileOut.write(data, 0, count)
|
||||||
}
|
}
|
||||||
if (count == -1)
|
println()
|
||||||
break
|
logger.info { "Downloading WebUI Done." }
|
||||||
webUIZipFileOut.write(data, 0, count)
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.info { "Using the bundled WebUI zip..." }
|
||||||
|
|
||||||
|
resourceWebUI.use { input ->
|
||||||
|
webUIZipFile.outputStream().use { output ->
|
||||||
|
input.copyTo(output)
|
||||||
}
|
}
|
||||||
println()
|
|
||||||
logger.info { "Downloading WebUI Done." }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract webUI zip
|
// extract webUI zip
|
||||||
logger.info { "Extracting downloaded WebUI zip..." }
|
logger.info { "Extracting WebUI zip..." }
|
||||||
File(applicationDirs.webUIRoot).mkdirs()
|
File(applicationDirs.webUIRoot).mkdirs()
|
||||||
ZipFile(webUIZipPath).extractAll(applicationDirs.webUIRoot)
|
ZipFile(webUIZipPath).extractAll(applicationDirs.webUIRoot)
|
||||||
logger.info { "Extracting downloaded WebUI zip Done." }
|
logger.info { "Extracting WebUI zip Done." }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user