diff --git a/.gitignore b/.gitignore index dea6d9d7..99232f52 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ build/ *.class *.log *.settings.xml +tmp/ +Tachidesk.jar # Eclipse .classpath diff --git a/build.gradle.kts b/build.gradle.kts index 1cada739..5d5e1c72 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -81,7 +81,17 @@ compose.desktop { application { mainClass = "ca.gosyer.ui.main.MainKt" nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + targetFormats( + // Windows + TargetFormat.Msi, + TargetFormat.Exe, + // Linux + TargetFormat.Deb, + TargetFormat.Rpm, + // MacOS + TargetFormat.Pkg + ) + packageName = "TachideskJUI" } } diff --git a/scripts/BuildLinuxDeb.sh b/scripts/BuildLinuxDeb.sh new file mode 100644 index 00000000..99f27ab1 --- /dev/null +++ b/scripts/BuildLinuxDeb.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if [ "$(basename "$(pwd)")" = "scripts" ]; then + cd .. +fi + +if test -f "src/main/resources/Tachidesk.jar"; then + echo "Tachidesk.jar already exists" +else + scripts/SetupUnix.sh +fi + + +echo "Building Deb package" +./gradlew packageDeb \ No newline at end of file diff --git a/scripts/BuildLinuxRpm.sh b/scripts/BuildLinuxRpm.sh new file mode 100644 index 00000000..7897c9b4 --- /dev/null +++ b/scripts/BuildLinuxRpm.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +if [ "$(basename "$(pwd)")" = "scripts" ]; then + cd .. +fi + +if test -f "src/main/resources/Tachidesk.jar"; then + echo "Tachidesk.jar already exists" +else + scripts/SetupUnix.sh +fi + +echo "Building Rpm package" +./gradlew packageRpm \ No newline at end of file diff --git a/scripts/BuildMacPkg.sh b/scripts/BuildMacPkg.sh new file mode 100644 index 00000000..5c042d68 --- /dev/null +++ b/scripts/BuildMacPkg.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if [ "$(basename "$(pwd)")" = "scripts" ]; then + cd .. +fi + +if test -f "src/main/resources/Tachidesk.jar"; then + echo "Tachidesk.jar already exists" +else + scripts/SetupUnix.sh +fi + + +echo "Building Deb package" +./gradlew packagePkg \ No newline at end of file diff --git a/scripts/BuildWindowsExe.ps1 b/scripts/BuildWindowsExe.ps1 new file mode 100644 index 00000000..568edb81 --- /dev/null +++ b/scripts/BuildWindowsExe.ps1 @@ -0,0 +1,14 @@ +if ($(Split-Path -Path (Get-Location) -Leaf) -eq "scripts" ) { + Set-Location .. +} + +if (Test-Path "src/main/resources/Tachidesk.jar" -PathType leaf) +{ + Write-Output "Tachidesk.jar already exists" +} +else +{ + &"./scripts/SetupWindows.ps1" +} + +&"./gradlew" packageExe \ No newline at end of file diff --git a/scripts/BuildWindowsMsi.ps1 b/scripts/BuildWindowsMsi.ps1 new file mode 100644 index 00000000..e648c257 --- /dev/null +++ b/scripts/BuildWindowsMsi.ps1 @@ -0,0 +1,14 @@ +if ($(Split-Path -Path (Get-Location) -Leaf) -eq "scripts" ) { + Set-Location .. +} + +if (Test-Path "src/main/resources/Tachidesk.jar" -PathType leaf) +{ + Write-Output "Tachidesk.jar already exists" +} +else +{ + &"./scripts/SetupWindows.ps1" +} + +&"./gradlew" packageMsi \ No newline at end of file diff --git a/scripts/SetupUnix.sh b/scripts/SetupUnix.sh new file mode 100644 index 00000000..d47155d1 --- /dev/null +++ b/scripts/SetupUnix.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +if [ "$(basename "$(pwd)")" = "scripts" ]; then + cd .. +fi + +mkdir -p "tmp" + +echo "Getting latest Tachidesk build files" +TARBALL_LINK="$(curl -s "https://api.github.com/repos/Suwayomi/Tachidesk/releases/latest" | grep -o "https.*tarball\/[a-zA-Z0-9.]*")" + +curl -L "$TARBALL_LINK" -o tmp/Tachidesk.tar + +tar -xvf tmp/Tachidesk.tar -C tmp + +TACHIDESK_FOLDER=$(find tmp -type d -regex ".*Tachidesk-[a-z0-9]*") + +pushd "$TACHIDESK_FOLDER" || exit + +echo "Setting up android.jar" +AndroidCompat/getAndroid.sh + +echo "Building Tachidesk.jar" +./gradlew :server:shadowJar -x :webUI:copyBuild + +TACHIDESK_JAR=$(find server/build -type f -regex ".*\.jar") + +popd || exit + +echo "Copying Tachidesk.jar to resources folder..." +mv "$TACHIDESK_FOLDER/$TACHIDESK_JAR" src/main/resources/Tachidesk.jar + +echo "Cleaning up..." +rm -rf "tmp" + +echo "Done!" \ No newline at end of file diff --git a/scripts/SetupWindows.ps1 b/scripts/SetupWindows.ps1 new file mode 100644 index 00000000..3f6f0747 --- /dev/null +++ b/scripts/SetupWindows.ps1 @@ -0,0 +1,35 @@ +if ($(Split-Path -Path (Get-Location) -Leaf) -eq "scripts" ) { + Set-Location .. +} + +Remove-Item -Recurse -Force "tmp" | Out-Null +New-Item -ItemType Directory -Force -Path "tmp" + +Write-Output "Getting latest Tachidesk build files" +$zipball = (Invoke-WebRequest -Uri "https://api.github.com/repos/Suwayomi/Tachidesk/releases/latest").content | Select-String -Pattern 'https[\.:\/A-Za-z0-9]*zipball\/[a-zA-Z0-9.]*' -CaseSensitive + +Invoke-WebRequest -Uri $zipball.Matches.Value -OutFile tmp/Tachidesk.zip + +Expand-Archive -Path "tmp/Tachidesk.zip" -DestinationPath "tmp" + +$tachidesk_folder = Get-ChildItem -Path "tmp" | Where-Object {$_.Name -match ".*Tachidesk-[a-z0-9]*"} | Select-Object FullName + +Push-Location $tachidesk_folder.FullName + +Write-Output "Setting up android.jar" +&"./AndroidCompat/getAndroid.ps1" + +Write-Output "Building Tachidesk.jar" +&"./gradlew" :server:shadowJar -x :webUI:copyBuild + +$tachidesk_jar = $(Get-ChildItem "server/build" | Where-Object { $_.Name -match '.*\.jar' })[0].FullName + +Pop-Location + +Write-Output "Copying Tachidesk.jar to resources folder..." +Move-Item -Force $tachidesk_jar "src/main/resources/Tachidesk.jar" + +Write-Output "Cleaning up..." +Remove-Item -Recurse -Force "tmp" | Out-Null + +Write-Output "Done!" \ No newline at end of file