diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 6e3fcab..ed6be84 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -380,6 +380,84 @@ jobs: mv "$deb_out" artifacts/ echo "Built native DEB: artifacts/$deb_out" + - name: Build Flatpak Bundle + shell: bash + run: | + version="${{ steps.get_version.outputs.VERSION }}" + + # Install flatpak-builder + sudo apt-get install -y flatpak-builder + flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + + # Define manifest ID + APP_ID="io.github.oop7.YTSage" + + # Create manifest manually + cat > ytsage_flatpak.json </dev/null | head -n1) + if [ -z "$build_dir" ]; then + echo "Error: build/exe.* directory not found for Flatpak build" >&2 + exit 1 + fi + + # Move build dir to a fixed location for the manifest source to catch + mkdir -p dist/ytsage-v${version}-flatpak + cp -r "$build_dir"/* "dist/ytsage-v${version}-flatpak/" + + # Install runtime/sdk + flatpak install -y --user flathub org.kde.Platform//6.6 org.kde.Sdk//6.6 + + # Build + flatpak-builder --user --install-deps-from=flathub --repo=repo --force-clean build-flatpak ytsage_flatpak.json + + # Bundle + flatpak build-bundle repo artifacts/YTSage-v${version}-x86_64.flatpak $APP_ID + echo "Built Flatpak: artifacts/YTSage-v${version}-x86_64.flatpak" + - name: Package and prepare release artifacts (.AppImage, .rpm, .deb) shell: bash run: | @@ -407,6 +485,9 @@ jobs: # DEB is already staged in artifacts by the native packaging step ls -1 artifacts/*.deb 2>/dev/null || echo "Warning: No .deb found in artifacts/" + # Check for Flatpak + ls -1 artifacts/*.flatpak 2>/dev/null || echo "Warning: No .flatpak found in artifacts/" + echo "Final artifacts:" ls -lh artifacts || true diff --git a/src/utils/ytsage_constants.py b/src/utils/ytsage_constants.py index 09faa1b..2f4d7b2 100644 --- a/src/utils/ytsage_constants.py +++ b/src/utils/ytsage_constants.py @@ -138,7 +138,13 @@ else: # Linux and other UNIX-like APP_THUMBNAILS_DIR: Path = APP_DATA_DIR / "thumbnails" YTDLP_DOWNLOAD_URL: str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp" - YTDLP_APP_BIN_PATH: Path = APP_BIN_DIR / "yt-dlp" + + # Check for environment variable override (critical for Flatpak support) + _ytdlp_env_path = os.environ.get("YTDLP_APP_BIN_PATH") + if _ytdlp_env_path: + YTDLP_APP_BIN_PATH: Path = Path(_ytdlp_env_path) + else: + YTDLP_APP_BIN_PATH: Path = APP_BIN_DIR / "yt-dlp" SUBPROCESS_CREATIONFLAGS: int = 0 @@ -194,3 +200,7 @@ else: APP_DATA_DIR.mkdir(parents=True, exist_ok=True) APP_LOG_DIR.mkdir(parents=True, exist_ok=True) APP_THUMBNAILS_DIR.mkdir(parents=True, exist_ok=True) + + # Ensure custom yt-dlp directory exists if set + if OS_NAME not in ["Windows", "Darwin"]: + YTDLP_APP_BIN_PATH.parent.mkdir(parents=True, exist_ok=True)