From 7e4838a56ca853d6f7df4f12bfb33add7fa77e8f Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 14:17:43 -0400 Subject: [PATCH 1/8] [9] Fix release workflow --- cmp/desktopApp/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmp/desktopApp/build.gradle.kts b/cmp/desktopApp/build.gradle.kts index 537d23ac..1cfba4b5 100644 --- a/cmp/desktopApp/build.gradle.kts +++ b/cmp/desktopApp/build.gradle.kts @@ -31,9 +31,9 @@ compose.desktop { jvmArgs("-Dsun.awt.wmclass=lion-vpn") nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) packageName = "lion-vpn" - packageVersion = rootProject.extra["versionName"] as String + val rawVersion = rootProject.extra["versionName"] as String + packageVersion = rawVersion.split("-")[0] appResourcesRootDir.set(project.layout.projectDirectory.dir("src/main/resources")) macOS { From 36263f66b7c95c4ec1b3810663b303a7a3252a48 Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 14:25:26 -0400 Subject: [PATCH 2/8] fix --- .github/workflows/desktop_gui_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/desktop_gui_release.yml b/.github/workflows/desktop_gui_release.yml index 29edc343..88ac2f63 100644 --- a/.github/workflows/desktop_gui_release.yml +++ b/.github/workflows/desktop_gui_release.yml @@ -72,7 +72,7 @@ jobs: working-directory: cmp run: | chmod +x gradlew - ./gradlew :desktopApp:createDistributableForCurrentOS --no-daemon + ./gradlew :desktopApp:createDistributable --no-daemon - name: Compress Distributable shell: bash From ef965c699b8f9f4432a1a356229321565926c218 Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 15:07:00 -0400 Subject: [PATCH 3/8] fix config.example.json not found --- .github/workflows/desktop_gui_release.yml | 5 ++++- cmp/bundle_for_gui.py | 9 --------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/desktop_gui_release.yml b/.github/workflows/desktop_gui_release.yml index 88ac2f63..6457a115 100644 --- a/.github/workflows/desktop_gui_release.yml +++ b/.github/workflows/desktop_gui_release.yml @@ -16,7 +16,7 @@ on: publish: description: "Publish GitHub release" required: false - default: true + default: false type: boolean permissions: @@ -78,10 +78,13 @@ jobs: shell: bash run: | if [ "${{ matrix.platform }}" = "windows" ]; then + cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/app/ powershell -Command "Compress-Archive -Path cmp/desktopApp/build/compose/binaries/main/app -DestinationPath ${{ matrix.archive-name }}" elif [ "${{ matrix.platform }}" = "linux" ]; then + cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/app/ tar -czf ${{ matrix.archive-name }} -C cmp/desktopApp/build/compose/binaries/main app elif [ "${{ matrix.platform }}" = "macos" ]; then + cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/lion-vpn.app/Contents/Resources/ cd cmp/desktopApp/build/compose/binaries/main/app zip -r -y ../../../../../../../${{ matrix.archive-name }} lion-vpn.app fi diff --git a/cmp/bundle_for_gui.py b/cmp/bundle_for_gui.py index aa55778b..1e84b97b 100644 --- a/cmp/bundle_for_gui.py +++ b/cmp/bundle_for_gui.py @@ -127,15 +127,6 @@ def main() -> int: log(f"Platform detected: {platform_name}") log(f"Target path: {dest_path}") - # Copy config.example.json to common resources so it is always packaged - common_resources_dir = repo_root / "cmp" / "desktopApp" / "src" / "main" / "resources" - common_resources_dir.mkdir(parents=True, exist_ok=True) - example_src = repo_root / "config.example.json" - example_dest = common_resources_dir / "config.example.json" - if example_src.exists(): - log(f"Copying config.example.json to {example_dest}") - shutil.copy2(example_src, example_dest) - # 2. Check if we need to compile (Incremental Build) if not args.force and dest_path.exists(): # Check source file modification times From f098f97484c505bfbe66980af3c253464a140742 Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 15:18:51 -0400 Subject: [PATCH 4/8] fix the ci --- .github/workflows/desktop_gui_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/desktop_gui_release.yml b/.github/workflows/desktop_gui_release.yml index 6457a115..80d9065c 100644 --- a/.github/workflows/desktop_gui_release.yml +++ b/.github/workflows/desktop_gui_release.yml @@ -78,10 +78,10 @@ jobs: shell: bash run: | if [ "${{ matrix.platform }}" = "windows" ]; then - cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/app/ + cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/app/resources/ powershell -Command "Compress-Archive -Path cmp/desktopApp/build/compose/binaries/main/app -DestinationPath ${{ matrix.archive-name }}" elif [ "${{ matrix.platform }}" = "linux" ]; then - cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/app/ + cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/lib/resources/ tar -czf ${{ matrix.archive-name }} -C cmp/desktopApp/build/compose/binaries/main app elif [ "${{ matrix.platform }}" = "macos" ]; then cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/lion-vpn.app/Contents/Resources/ From 76b08e29197eb8468892f72fcc2fc7be7e38c6f7 Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 15:47:38 -0400 Subject: [PATCH 5/8] test --- cmp/bundle_for_gui.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmp/bundle_for_gui.py b/cmp/bundle_for_gui.py index 1e84b97b..10932173 100644 --- a/cmp/bundle_for_gui.py +++ b/cmp/bundle_for_gui.py @@ -165,9 +165,13 @@ def main() -> int: ] try: - subprocess.run(cmd, check=True) + subprocess.run(cmd, check=True, capture_output=True, text=True) except subprocess.CalledProcessError as e: error(f"PyInstaller execution failed: {e}") + print("--- PYINSTALLER STDOUT ---", file=sys.stderr) + print(e.stdout, file=sys.stderr) + print("--- PYINSTALLER STDERR ---", file=sys.stderr) + print(e.stderr, file=sys.stderr) return 1 # 5. Move executable to resources From 6c6559dcd11e700b5e21122e25b43e12382b578f Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 16:25:55 -0400 Subject: [PATCH 6/8] fix --- .github/workflows/desktop_gui_release.yml | 3 - .../com/darius/lionvpn/ConfigProvider.kt | 55 ++----------------- .../com/darius/lionvpn/PythonProvider.kt | 15 ++--- 3 files changed, 9 insertions(+), 64 deletions(-) diff --git a/.github/workflows/desktop_gui_release.yml b/.github/workflows/desktop_gui_release.yml index 80d9065c..b7cac1a0 100644 --- a/.github/workflows/desktop_gui_release.yml +++ b/.github/workflows/desktop_gui_release.yml @@ -78,13 +78,10 @@ jobs: shell: bash run: | if [ "${{ matrix.platform }}" = "windows" ]; then - cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/app/resources/ powershell -Command "Compress-Archive -Path cmp/desktopApp/build/compose/binaries/main/app -DestinationPath ${{ matrix.archive-name }}" elif [ "${{ matrix.platform }}" = "linux" ]; then - cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/lib/resources/ tar -czf ${{ matrix.archive-name }} -C cmp/desktopApp/build/compose/binaries/main app elif [ "${{ matrix.platform }}" = "macos" ]; then - cp config.example.json cmp/desktopApp/build/compose/binaries/main/app/lion-vpn.app/Contents/Resources/ cd cmp/desktopApp/build/compose/binaries/main/app zip -r -y ../../../../../../../${{ matrix.archive-name }} lion-vpn.app fi diff --git a/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt b/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt index c2f8f21a..935fcc8c 100644 --- a/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt +++ b/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt @@ -5,67 +5,22 @@ import java.io.File import kotlinx.serialization.json.Json import com.darius.lionvpn.ui.model.SavedConfig -fun loadSavedConfig(): Pair { - return try { - val binaryPath = getPythonExecutablePath() - val binaryFile = File(binaryPath) - val configFile = if (binaryFile.parentFile != null) { - File(binaryFile.parentFile, "config.json") - } else { - File(findResourcesDir(), "config.json") - } - - if (configFile.exists()) { - val content = configFile.readText(Charsets.UTF_8) - - // Clean extraction of script_id and auth_key values using simple regex - val scriptIdRegex = "\"script_id\"\\s*:\\s*\"([^\"]+)\"".toRegex() - val authKeyRegex = "\"auth_key\"\\s*:\\s*\"([^\"]+)\"".toRegex() - - val scriptId = scriptIdRegex.find(content)?.groupValues?.get(1) ?: "" - val authKey = authKeyRegex.find(content)?.groupValues?.get(1) ?: "" - - // Filter out default placeholder values to keep text inputs clean - val filteredScriptId = if (scriptId == "YOUR_APPS_SCRIPT_DEPLOYMENT_ID") "" else scriptId - val filteredAuthKey = if (authKey == "CHANGE_ME_TO_A_STRONG_SECRET") "" else authKey - - return Pair(filteredScriptId, filteredAuthKey) - } - throw IOException("File does not exist") - } catch (e: IOException) { - println("[Config JVM] Error loading saved config: ${e.message}") - Pair("", "") - } -} - fun saveConfigLocally(deploymentId: String, authKey: String): Boolean { return try { - val resourcesDir = findResourcesDir() - val exampleFile = File(resourcesDir, "config.example.json") + val root = findRepoRoot() + val exampleFile = File(root, "config.example.json") val binaryPath = getPythonExecutablePath() val binaryFile = File(binaryPath) - // Write config.json in the exact same platform-specific directory containing the python executable - val configFile = if (binaryFile.parentFile != null) { - File(binaryFile.parentFile, "config.json") - } else { - File(resourcesDir, "config.json") - } - - // If config.example.json doesn't exist in resourcesDir, check fallback for dev mode - val resolvedExampleFile = if (exampleFile.exists()) { - exampleFile - } else { - File(findRepoRoot(), "config.example.json") - } + val configFile = File(binaryFile.parentFile, "config.json") - if (!resolvedExampleFile.exists()) { + if (!exampleFile.exists()) { println("[Config JVM] ERROR: config.example.json not found!") return false } - var content = resolvedExampleFile.readText(Charsets.UTF_8) + var content = exampleFile.readText(Charsets.UTF_8) // Safe drop-in replacements for the script ID and Auth Key placeholders content = content.replace("YOUR_APPS_SCRIPT_DEPLOYMENT_ID", deploymentId) diff --git a/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/PythonProvider.kt b/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/PythonProvider.kt index 5f3654db..ec8c1244 100644 --- a/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/PythonProvider.kt +++ b/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/PythonProvider.kt @@ -1,19 +1,12 @@ package com.darius.lionvpn +import kotlinx.io.files.FileNotFoundException import java.io.File -private const val DIR_LEVEL = 4 fun findRepoRoot(): File { - var dir = File(System.getProperty("user.dir")).absoluteFile - var dirLevel = DIR_LEVEL - while (dirLevel > 0) { - dirLevel-- - if (File(dir, "config.example.json").exists()) { - return dir - } - dir = dir.parentFile ?: break - } - return File(System.getProperty("user.dir")).absoluteFile + val dir = File(System.getProperty("user.dir")).parentFile + return if (File(dir, "config.example.json").exists()) dir + else throw FileNotFoundException() } fun findResourcesDir(): File { From 046c33b6bba8d3e95f50ce7ec3c70d982a587041 Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 17:06:10 -0400 Subject: [PATCH 7/8] fix --- .github/workflows/desktop_gui_release.yml | 44 ++++++++++--------- cmp/bundle_for_gui.py | 8 ++++ .../com/darius/lionvpn/ConfigProvider.kt | 7 ++- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/desktop_gui_release.yml b/.github/workflows/desktop_gui_release.yml index b7cac1a0..3e7bfeb8 100644 --- a/.github/workflows/desktop_gui_release.yml +++ b/.github/workflows/desktop_gui_release.yml @@ -62,35 +62,24 @@ jobs: python -m pip install --upgrade pip python -m pip install -r requirements.txt pyinstaller - - name: Bundle Python Executable into Compose Resources + - name: Bundle Python Executable shell: bash + working-directory: cmp run: | - python cmp/bundle_for_gui.py --force + chmod +x gradlew + ./gradlew :desktopApp:bundlePythonExecutable --no-daemon - name: Build Desktop Application Distributable shell: bash working-directory: cmp run: | - chmod +x gradlew ./gradlew :desktopApp:createDistributable --no-daemon - - name: Compress Distributable - shell: bash - run: | - if [ "${{ matrix.platform }}" = "windows" ]; then - powershell -Command "Compress-Archive -Path cmp/desktopApp/build/compose/binaries/main/app -DestinationPath ${{ matrix.archive-name }}" - elif [ "${{ matrix.platform }}" = "linux" ]; then - tar -czf ${{ matrix.archive-name }} -C cmp/desktopApp/build/compose/binaries/main app - elif [ "${{ matrix.platform }}" = "macos" ]; then - cd cmp/desktopApp/build/compose/binaries/main/app - zip -r -y ../../../../../../../${{ matrix.archive-name }} lion-vpn.app - fi - - - name: Upload Compressed Distributable Artifact + - name: Upload Raw Distributable Artifact uses: actions/upload-artifact@v4 with: name: gui-${{ matrix.platform }} - path: ${{ matrix.archive-name }} + path: cmp/desktopApp/build/compose/binaries/main/app if-no-files-found: error publish-gui-release: @@ -123,11 +112,26 @@ jobs: with: path: final-gui-assets - - name: Flatten directories + - name: Prepare and Compress Assets for Release run: | mkdir -p release-dist - find final-gui-assets -type f -exec cp {} release-dist/ \; - echo "Files to publish:" + + # Compress Windows (gui-windows contains the files of app/ directly) + cd final-gui-assets/gui-windows + zip -r ../../release-dist/lion-vpn-windows.zip . + cd ../.. + + # Compress Linux (gui-linux contains the files of app/ directly) + cd final-gui-assets/gui-linux + tar -czf ../../release-dist/lion-vpn-linux.tar.gz . + cd ../.. + + # Compress macOS (gui-macos contains the lion-vpn.app folder directly) + cd final-gui-assets/gui-macos + zip -r -y ../../release-dist/lion-vpn-macos.zip lion-vpn.app + cd ../.. + + echo "Compressed release files:" ls -lah release-dist - name: Create GitHub Release diff --git a/cmp/bundle_for_gui.py b/cmp/bundle_for_gui.py index 10932173..fde93f71 100644 --- a/cmp/bundle_for_gui.py +++ b/cmp/bundle_for_gui.py @@ -127,6 +127,14 @@ def main() -> int: log(f"Platform detected: {platform_name}") log(f"Target path: {dest_path}") + # Copy config.example.json to common resources so it is always packaged + dest_dir.mkdir(parents=True, exist_ok=True) + example_src = repo_root / "config.example.json" + example_dest = dest_dir / "config.example.json" + if example_src.exists(): + log(f"Copying config.example.json to {example_dest}") + shutil.copy2(example_src, example_dest) + # 2. Check if we need to compile (Incremental Build) if not args.force and dest_path.exists(): # Check source file modification times diff --git a/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt b/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt index 935fcc8c..829b02aa 100644 --- a/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt +++ b/cmp/desktopApp/src/main/kotlin/com/darius/lionvpn/ConfigProvider.kt @@ -7,8 +7,11 @@ import com.darius.lionvpn.ui.model.SavedConfig fun saveConfigLocally(deploymentId: String, authKey: String): Boolean { return try { - val root = findRepoRoot() - val exampleFile = File(root, "config.example.json") + val root = findResourcesDir() + var exampleFile = File(root, "config.example.json") + if (!exampleFile.exists()) { + exampleFile = File(findRepoRoot(), "config.example.json") + } val binaryPath = getPythonExecutablePath() val binaryFile = File(binaryPath) From 2f2f83f8141ac3fed21afb9d29adbd388ffbe831 Mon Sep 17 00:00:00 2001 From: Dariush Malek Date: Fri, 22 May 2026 22:56:52 -0400 Subject: [PATCH 8/8] get rid of gui-platform dir --- .github/workflows/desktop_gui_release.yml | 46 ++++++++++++++--------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/.github/workflows/desktop_gui_release.yml b/.github/workflows/desktop_gui_release.yml index 3e7bfeb8..d708d75c 100644 --- a/.github/workflows/desktop_gui_release.yml +++ b/.github/workflows/desktop_gui_release.yml @@ -32,13 +32,16 @@ jobs: include: - os: windows-latest platform: windows - archive-name: lion-vpn-windows.zip + artifact-name: lion-vpn-windows + upload-path: cmp/desktopApp/build/compose/binaries/main/app/lion-vpn - os: ubuntu-latest platform: linux - archive-name: lion-vpn-linux.tar.gz + artifact-name: lion-vpn-linux + upload-path: cmp/desktopApp/build/compose/binaries/main/app/lion-vpn - os: macos-latest platform: macos - archive-name: lion-vpn-macos.zip + artifact-name: lion-vpn-macos + upload-path: cmp/desktopApp/build/compose/binaries/main/app/lion-vpn.app steps: - name: Checkout Repository @@ -78,8 +81,8 @@ jobs: - name: Upload Raw Distributable Artifact uses: actions/upload-artifact@v4 with: - name: gui-${{ matrix.platform }} - path: cmp/desktopApp/build/compose/binaries/main/app + name: ${{ matrix.artifact-name }} + path: ${{ matrix.upload-path }} if-no-files-found: error publish-gui-release: @@ -116,20 +119,29 @@ jobs: run: | mkdir -p release-dist - # Compress Windows (gui-windows contains the files of app/ directly) - cd final-gui-assets/gui-windows - zip -r ../../release-dist/lion-vpn-windows.zip . - cd ../.. + # Compress Windows + mkdir -p temp-win + mv final-gui-assets/lion-vpn-windows temp-win/lion-vpn + cd temp-win + zip -r ../release-dist/lion-vpn-windows.zip lion-vpn + cd .. + rm -rf temp-win - # Compress Linux (gui-linux contains the files of app/ directly) - cd final-gui-assets/gui-linux - tar -czf ../../release-dist/lion-vpn-linux.tar.gz . - cd ../.. + # Compress Linux + mkdir -p temp-linux + mv final-gui-assets/lion-vpn-linux temp-linux/lion-vpn + cd temp-linux + tar -czf ../release-dist/lion-vpn-linux.tar.gz lion-vpn + cd .. + rm -rf temp-linux - # Compress macOS (gui-macos contains the lion-vpn.app folder directly) - cd final-gui-assets/gui-macos - zip -r -y ../../release-dist/lion-vpn-macos.zip lion-vpn.app - cd ../.. + # Compress macOS + mkdir -p temp-mac + mv final-gui-assets/lion-vpn-macos temp-mac/lion-vpn.app + cd temp-mac + zip -r -y ../release-dist/lion-vpn-macos.zip lion-vpn.app + cd .. + rm -rf temp-mac echo "Compressed release files:" ls -lah release-dist