diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 08ed905..ffdcbbc 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -75,14 +75,29 @@ jobs: ./windows-bundler.sh win32 ./windows-bundler.sh win64 - - name: Checkout preview branch - uses: actions/checkout@v2 - with: - repository: 'Suwayomi/Tachidesk-preview' - ref: main - path: preview - token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }} +# - name: Checkout preview branch +# uses: actions/checkout@v2 +# with: +# repository: 'Suwayomi/Tachidesk-preview' +# ref: main +# path: preview +# token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }} - - name: Deploy preview - run: | - ./master/.github/scripts/commit-preview.sh \ No newline at end of file + - name: Upload Release + uses: ncipollo/release-action@v1 + 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 \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 215d012..bf51c95 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -75,11 +75,11 @@ jobs: ./windows-bundler.sh win64 - name: Upload Release - uses: xresloader/upload-to-github-release@master + uses: xresloader/upload-to-github-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - file: "master/server/build/*.jar;master/server/build/*.z*" + file: "master/server/build/*.jar;master/server/build/*.zip" tags: true draft: true verbose: true diff --git a/.gitignore b/.gitignore index edd97d9..931397a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ server/tachiserver-data/ # bundle asset downlaods OpenJDK*.zip electron-*.zip +rcedit-* diff --git a/scripts/resources/Tachidesk Launcher.bat b/scripts/resources/Tachidesk Browser Launcher.bat similarity index 100% rename from scripts/resources/Tachidesk Launcher.bat rename to scripts/resources/Tachidesk Browser Launcher.bat diff --git a/scripts/resources/Tachidesk Electron Launcher.bat b/scripts/resources/Tachidesk Electron Launcher.bat index 679cf55..0799e8e 100644 --- a/scripts/resources/Tachidesk Electron Launcher.bat +++ b/scripts/resources/Tachidesk Electron Launcher.bat @@ -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 diff --git a/scripts/windows-bundler.sh b/scripts/windows-bundler.sh index 27c98b5..5007869 100755 --- a/scripts/windows-bundler.sh +++ b/scripts/windows-bundler.sh @@ -6,14 +6,16 @@ # 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/. +electron_version="v12.0.9" + if [ $1 = "win32" ]; then jre="OpenJDK8U-jre_x86-32_windows_hotspot_8u292b10.zip" arch="win32" - electron="electron-v12.0.9-win32-ia32.zip" + electron="electron-$electron_version-win32-ia32.zip" else jre="OpenJDK8U-jre_x64_windows_hotspot_8u292b10.zip" arch="win64" - electron="electron-v12.0.9-win32-x64.zip" + electron="electron-$electron_version-win32-x64.zip" fi jre_dir="jdk8u292-b10-jre" @@ -38,26 +40,44 @@ mv $jre_dir $release_name/jre echo "Dealing with electron" 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 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 cp $jar $release_name/Tachidesk.jar -cp "resources/Tachidesk Launcher-$arch.exe" "$release_name/Tachidesk Launcher.exe" -cp "resources/Tachidesk Launcher.bat" $release_name +#cp "resources/Tachidesk Launcher-$arch.exe" "$release_name/Tachidesk Launcher.exe" +cp "resources/Tachidesk Browser Launcher.bat" $release_name cp "resources/Tachidesk Debug Launcher.bat" $release_name cp "resources/Tachidesk Electron Launcher.bat" $release_name zip_name=$release_name.zip -zip -9 -s90 -r $zip_name $release_name +zip -9 -r $zip_name $release_name rm -rf $release_name - # clean up from possible previous runs if [ -f ../server/build/$zip_name ]; then - rm ../server/build/$release_name.z* + rm ../server/build/$zip_name fi -mv $release_name.z* ../server/build/ +mv $zip_name ../server/build/ diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 7a10b2d..eb967d5 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -75,7 +75,12 @@ dependencies { val MainClass = "ir.armor.tachidesk.MainKt" application { 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 { diff --git a/server/src/main/kotlin/ir/armor/tachidesk/server/util/Browser.kt b/server/src/main/kotlin/ir/armor/tachidesk/server/util/Browser.kt index d24f46b..6f916a0 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/server/util/Browser.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/util/Browser.kt @@ -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 appBaseUrl = "http://$appIP:${serverConfig.port}" - private val webViewInstances = mutableListOf() + private val electronInstances = mutableListOf() 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 { - // 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 e.printStackTrace() }