Electron launcher

This commit is contained in:
Aria Moradi 2021-05-24 15:37:25 +04:30
parent 71661f70b6
commit 08e8a9d105
8 changed files with 69 additions and 27 deletions

View File

@ -75,14 +75,29 @@ jobs:
./windows-bundler.sh win32 ./windows-bundler.sh win32
./windows-bundler.sh win64 ./windows-bundler.sh win64
- name: Checkout preview branch # - name: Checkout preview branch
uses: actions/checkout@v2 # uses: actions/checkout@v2
with: # with:
repository: 'Suwayomi/Tachidesk-preview' # repository: 'Suwayomi/Tachidesk-preview'
ref: main # ref: main
path: preview # path: preview
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }} # token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
- name: Deploy preview - name: Upload Release
run: | uses: ncipollo/release-action@v1
./master/.github/scripts/commit-preview.sh with:
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
artifacts: "master/server/build/*.jar,master/server/build/*.zip"
draft: true
owner: "Suwayomi"
repo: "Tachidesk-preview"
# - name: Upload Release
# uses: xresloader/upload-to-github-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# file: "master/server/build/*.jar;master/server/build/*.zip"
# draft: false
# verbose: true

View File

@ -75,11 +75,11 @@ jobs:
./windows-bundler.sh win64 ./windows-bundler.sh win64
- name: Upload Release - name: Upload Release
uses: xresloader/upload-to-github-release@master uses: xresloader/upload-to-github-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
file: "master/server/build/*.jar;master/server/build/*.z*" file: "master/server/build/*.jar;master/server/build/*.zip"
tags: true tags: true
draft: true draft: true
verbose: true verbose: true

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ server/tachiserver-data/
# bundle asset downlaods # bundle asset downlaods
OpenJDK*.zip OpenJDK*.zip
electron-*.zip electron-*.zip
rcedit-*

View File

@ -1 +1 @@
electron\electron.exe "http://127.0.0.1:4567" jre\bin\javaw "-Dir.armor.tachidesk.webInterface=electron" "-Dir.armor.tachidesk.electronPath=electron/electron.exe" -jar Tachidesk.jar

View File

@ -6,14 +6,16 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/. # file, You can obtain one at https://mozilla.org/MPL/2.0/.
electron_version="v12.0.9"
if [ $1 = "win32" ]; then if [ $1 = "win32" ]; then
jre="OpenJDK8U-jre_x86-32_windows_hotspot_8u292b10.zip" jre="OpenJDK8U-jre_x86-32_windows_hotspot_8u292b10.zip"
arch="win32" arch="win32"
electron="electron-v12.0.9-win32-ia32.zip" electron="electron-$electron_version-win32-ia32.zip"
else else
jre="OpenJDK8U-jre_x64_windows_hotspot_8u292b10.zip" jre="OpenJDK8U-jre_x64_windows_hotspot_8u292b10.zip"
arch="win64" arch="win64"
electron="electron-v12.0.9-win32-x64.zip" electron="electron-$electron_version-win32-x64.zip"
fi fi
jre_dir="jdk8u292-b10-jre" jre_dir="jdk8u292-b10-jre"
@ -38,26 +40,44 @@ mv $jre_dir $release_name/jre
echo "Dealing with electron" echo "Dealing with electron"
if [ ! -f $electron ]; then if [ ! -f $electron ]; then
curl -L "https://github.com/electron/electron/releases/download/v12.0.9/$electron" -o $electron curl -L "https://github.com/electron/electron/releases/download/$electron_version/$electron" -o $electron
fi fi
unzip $electron -d $release_name/electron unzip $electron -d $release_name/electron
# change electron's icon
rcedit="rcedit-x86.exe"
if [ ! -f $rcedit ]; then
curl -L "https://github.com/electron/rcedit/releases/download/v1.1.1/$rcedit" -o $rcedit
fi
# check if running under github actions
if [ $CI = true ]; then
# change electron executable's icon
sudo dpkg --add-architecture i386
wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add -
sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport
sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu $(lsb_release -cs) main"
sudo apt install --install-recommends winehq-stable
fi
# this script assumes that wine is installed here on out
WINEARCH=win32 wine $rcedit $release_name/electron/electron.exe --set-icon ../server/src/main/resources/icon/faviconlogo.ico
# copy artifacts # copy artifacts
cp $jar $release_name/Tachidesk.jar cp $jar $release_name/Tachidesk.jar
cp "resources/Tachidesk Launcher-$arch.exe" "$release_name/Tachidesk Launcher.exe" #cp "resources/Tachidesk Launcher-$arch.exe" "$release_name/Tachidesk Launcher.exe"
cp "resources/Tachidesk Launcher.bat" $release_name cp "resources/Tachidesk Browser Launcher.bat" $release_name
cp "resources/Tachidesk Debug Launcher.bat" $release_name cp "resources/Tachidesk Debug Launcher.bat" $release_name
cp "resources/Tachidesk Electron Launcher.bat" $release_name cp "resources/Tachidesk Electron Launcher.bat" $release_name
zip_name=$release_name.zip zip_name=$release_name.zip
zip -9 -s90 -r $zip_name $release_name zip -9 -r $zip_name $release_name
rm -rf $release_name rm -rf $release_name
# clean up from possible previous runs # clean up from possible previous runs
if [ -f ../server/build/$zip_name ]; then if [ -f ../server/build/$zip_name ]; then
rm ../server/build/$release_name.z* rm ../server/build/$zip_name
fi fi
mv $release_name.z* ../server/build/ mv $zip_name ../server/build/

View File

@ -75,7 +75,12 @@ dependencies {
val MainClass = "ir.armor.tachidesk.MainKt" val MainClass = "ir.armor.tachidesk.MainKt"
application { application {
mainClass.set(MainClass) mainClass.set(MainClass)
// applicationDefaultJvmArgs = listOf("-Dir.armor.tachidesk.openInWebview=true")
// for testing electron
// applicationDefaultJvmArgs = listOf(
// "-Dir.armor.tachidesk.webInterface=electron",
// "-Dir.armor.tachidesk.electronPath=/home/armor/programming/Suwayomi/Tachidesk/scripts/electron-v12.0.9-linux-x64/electron"
// )
} }
sourceSets { sourceSets {

View File

@ -14,15 +14,16 @@ object Browser {
private val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip private val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip
private val appBaseUrl = "http://$appIP:${serverConfig.port}" private val appBaseUrl = "http://$appIP:${serverConfig.port}"
private val webViewInstances = mutableListOf<Any>() private val electronInstances = mutableListOf<Any>()
fun openInBrowser() { fun openInBrowser() {
val openInWebView = System.getProperty("ir.armor.tachidesk.openInWebview")?.toBoolean() val openInElectron = System.getProperty("ir.armor.tachidesk.webInterface")?.equals("electron")
if (openInWebView == true) { if (openInElectron == true) {
try { try {
// TODO val electronPath = System.getProperty("ir.armor.tachidesk.electronPath")!!
electronInstances.add(ProcessBuilder(electronPath, appBaseUrl).start())
} catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error } catch (e: Throwable) { // cover both java.lang.Exception and java.lang.Error
e.printStackTrace() e.printStackTrace()
} }