Add setup and build scripts

Windows setup script will fail until the next release of Tachidesk
This commit is contained in:
Syer10
2021-03-25 01:25:18 -04:00
parent 5352ca6e71
commit 871c450783
9 changed files with 156 additions and 1 deletions

2
.gitignore vendored
View File

@@ -5,6 +5,8 @@ build/
*.class
*.log
*.settings.xml
tmp/
Tachidesk.jar
# Eclipse
.classpath

View File

@@ -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"
}
}

15
scripts/BuildLinuxDeb.sh Normal file
View File

@@ -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

14
scripts/BuildLinuxRpm.sh Normal file
View File

@@ -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

15
scripts/BuildMacPkg.sh Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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

36
scripts/SetupUnix.sh Normal file
View File

@@ -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!"

35
scripts/SetupWindows.ps1 Normal file
View File

@@ -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!"