diff --git a/.gitea/workflows/build-scribd.yml b/.gitea/workflows/build-scribd.yml index 870a6d5..2439beb 100644 --- a/.gitea/workflows/build-scribd.yml +++ b/.gitea/workflows/build-scribd.yml @@ -1,8 +1,7 @@ -# CI for a Linux-only Gitea runner (ubuntu-latest). -# -# - linux job: native .tar.gz with bundled Chromium (PyInstaller) -# - windows-portable job: zip for Windows (install .bat + source — runs on user's PC) -# True Windows .exe cannot be built on Linux (Playwright needs Windows binaries). +# Linux runner builds: +# - Linux native .tar.gz (PyInstaller) +# - Windows .exe zip (Docker + Wine cross-build) +# - Windows portable zip (fallback, no Docker) name: Build Scribd @@ -46,8 +45,27 @@ jobs: path: ${{ env.SCRIBD_DIR }}/dist/Scribd-PDF-Downloader-Linux.tar.gz retention-days: 14 + build-windows-exe: + name: Windows (.exe via Wine/Docker) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build Windows exe (cross-compile on Linux) + working-directory: ${{ env.SCRIBD_DIR }} + run: | + chmod +x ./build/ci/docker-build-windows.sh + ./build/ci/docker-build-windows.sh + + - uses: actions/upload-artifact@v4 + with: + name: scribd-windows + path: ${{ env.SCRIBD_DIR }}/dist/Scribd-PDF-Downloader-Windows.zip + retention-days: 14 + if-no-files-found: error + build-windows-portable: - name: Windows (portable zip) + name: Windows (portable zip fallback) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.gitea/workflows/release-scribd.yml b/.gitea/workflows/release-scribd.yml index 46ef0e1..7724dd0 100644 --- a/.gitea/workflows/release-scribd.yml +++ b/.gitea/workflows/release-scribd.yml @@ -1,5 +1,3 @@ -# Release — Linux native build + Windows portable zip (Linux runner only). - name: Release Scribd on: @@ -36,6 +34,19 @@ jobs: path: ${{ env.SCRIBD_DIR }}/dist/Scribd-PDF-Downloader-Linux.tar.gz retention-days: 30 + build-windows-exe: + name: Windows (.exe via Wine/Docker) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - working-directory: ${{ env.SCRIBD_DIR }} + run: chmod +x ./build/ci/docker-build-windows.sh && ./build/ci/docker-build-windows.sh + - uses: actions/upload-artifact@v4 + with: + name: scribd-windows + path: ${{ env.SCRIBD_DIR }}/dist/Scribd-PDF-Downloader-Windows.zip + retention-days: 30 + build-windows-portable: name: Windows (portable zip) runs-on: ubuntu-latest @@ -54,7 +65,7 @@ jobs: release: name: Create Gitea release - needs: [build-linux, build-windows-portable] + needs: [build-linux, build-windows-exe, build-windows-portable] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 diff --git a/.github/workflows/build-scribd.yml b/.github/workflows/build-scribd.yml index 600146b..04964a8 100644 --- a/.github/workflows/build-scribd.yml +++ b/.github/workflows/build-scribd.yml @@ -1,4 +1,4 @@ -# GitHub mirror — Linux runner: native Linux build + Windows portable zip +# GitHub mirror — same as .gitea/workflows/build-scribd.yml name: Build Scribd @@ -38,8 +38,22 @@ jobs: path: ${{ env.SCRIBD_DIR }}/dist/Scribd-PDF-Downloader-Linux.tar.gz retention-days: 14 + build-windows-exe: + name: Windows (.exe via Wine/Docker) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - working-directory: ${{ env.SCRIBD_DIR }} + run: chmod +x ./build/ci/docker-build-windows.sh && ./build/ci/docker-build-windows.sh + - uses: actions/upload-artifact@v4 + with: + name: scribd-windows + path: ${{ env.SCRIBD_DIR }}/dist/Scribd-PDF-Downloader-Windows.zip + retention-days: 14 + if-no-files-found: error + build-windows-portable: - name: Windows (portable zip) + name: Windows (portable zip fallback) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index b13273d..6d18217 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Hosted on [Gitea](https://git.masengr.com/Michael-A-Sloan/PDF-Downloaders). - Download **Artifacts** from the Actions tab after a green run - Tag `v1.0.0` to trigger [release-scribd.yml](.gitea/workflows/release-scribd.yml) -CI (Linux runner) builds **Linux app** + **Windows portable zip** on every push. See [Scribd/BUILD.md](Scribd/BUILD.md#ci-builds-gitea--github-actions). +CI on your Linux runner builds **Linux**, **Windows .exe** (Docker+Wine cross-build), and a **Windows portable** fallback. See [Scribd/BUILD.md](Scribd/BUILD.md#ci-builds-gitea--github-actions). ## Scribd diff --git a/Scribd/BUILD.md b/Scribd/BUILD.md index 17c4dcd..b6cb029 100644 --- a/Scribd/BUILD.md +++ b/Scribd/BUILD.md @@ -29,21 +29,39 @@ Automated builds for **Windows, macOS, and Linux** run from the repo root. #### Runners (match your other repos) -**Build Scribd** uses your **Linux runner** (`ubuntu-latest`) for two jobs: +**Build Scribd** on your **Linux runner** (`ubuntu-latest`) runs three jobs: -| Job | What you get | Notes | -|-----|----------------|-------| -| **Linux** | `Scribd-PDF-Downloader-Linux.tar.gz` | Full standalone app (PyInstaller + Chromium) | -| **Windows portable** | `Scribd-PDF-Downloader-Windows-Portable.zip` | Source + `Install Scribd Downloader.bat` | +| Job | Artifact | How | +|-----|----------|-----| +| **Linux** | `Scribd-PDF-Downloader-Linux.tar.gz` | Native PyInstaller | +| **Windows (.exe)** | `Scribd-PDF-Downloader-Windows.zip` | **Docker + Wine** cross-build | +| **Windows portable** | `Scribd-PDF-Downloader-Windows-Portable.zip` | Source + install `.bat` (fallback) | -### Why not a Windows `.exe` from Linux? +### Windows `.exe` from Linux (Docker + Wine) -Playwright ships **OS-specific Chromium**. PyInstaller cannot cross-compile this app from Linux to a real Windows `.exe`. That requires either: +CI runs `build/ci/docker-build-windows.sh`, which: -- A **Windows machine** / `windows-latest` runner, or -- Local build: `.\build\windows\build.ps1` on your PC +1. Builds image `build/docker/Dockerfile.cross-win` (Ubuntu + Wine + Windows Python 3.12) +2. Installs dependencies and Playwright **Windows** Chromium inside Wine +3. Runs **PyInstaller** inside Wine → real `Scribd PDF Downloader.exe` -### Windows portable zip (from Linux CI) +**Runner requirement:** Docker must be available to the act runner (socket mounted, user in `docker` group). + +Test locally on Linux: + +```bash +cd Scribd +chmod +x build/ci/docker-build-windows.sh +./build/ci/docker-build-windows.sh +``` + +This is **experimental** — Wine builds can be slow (~20–40 min) or fail on some packages. If it fails, use **scribd-windows-portable** or build on Windows with `.\build\windows\build.ps1`. + +### macOS from Linux? + +**Not supported.** macOS `.app` bundles require Xcode/tooling on real macOS (or a `macos-latest` runner). + +### Windows portable zip (fallback) 1. Download artifact **`scribd-windows-portable`** 2. Extract on a Windows PC @@ -82,10 +100,9 @@ Optional: add repo secret **`GITEA_TOKEN`** (releases scope) for `release-scribd | Artifact | File | |----------|------| | `scribd-linux` | `Scribd-PDF-Downloader-Linux.tar.gz` | +| `scribd-windows` | `Scribd-PDF-Downloader-Windows.zip` (`.exe` inside folder) | | `scribd-windows-portable` | `Scribd-PDF-Downloader-Windows-Portable.zip` | -For a full Windows `.exe`, build locally with `.\build\windows\build.ps1`. - > **Note:** Each archive is large (~500–900 MB) because Chromium is bundled. Hosted runners may hit artifact size limits; self-hosted runners avoid that. --- diff --git a/Scribd/build/ci/docker-build-windows.sh b/Scribd/build/ci/docker-build-windows.sh new file mode 100644 index 0000000..448de75 --- /dev/null +++ b/Scribd/build/ci/docker-build-windows.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Build a real Windows .exe from Linux using Docker + Wine. +# Requires: docker, run from Scribd/ project root (or repo sets working-directory). +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$ROOT" + +IMAGE="scribd-cross-win-builder" + +echo "=== Docker: build Windows image ===" +docker build -f build/docker/Dockerfile.cross-win -t "$IMAGE" . + +echo "=== Docker: run Windows cross-build ===" +docker run --rm --platform linux/amd64 \ + -v "$ROOT:/src" \ + -w /src \ + "$IMAGE" + +if [[ ! -f "$ROOT/dist/Scribd-PDF-Downloader-Windows.zip" ]]; then + echo "ERROR: dist/Scribd-PDF-Downloader-Windows.zip was not created" + exit 1 +fi + +echo "Done: $ROOT/dist/Scribd-PDF-Downloader-Windows.zip" diff --git a/Scribd/build/ci/docker-entrypoint-win.sh b/Scribd/build/ci/docker-entrypoint-win.sh new file mode 100644 index 0000000..edc6dea --- /dev/null +++ b/Scribd/build/ci/docker-entrypoint-win.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Runs inside Dockerfile.cross-win — produces dist/Scribd-PDF-Downloader-Windows.zip +set -euo pipefail + +export DISPLAY="${DISPLAY:-:99}" +Xvfb "$DISPLAY" -screen 0 1280x720x24 & +XVFB_PID=$! +trap "kill $XVFB_PID 2>/dev/null || true" EXIT + +cd /src + +WIN_PY='wine64 C:\\Python312\\python.exe' + +echo "=== Upgrading pip (Wine / Windows Python) ===" +$WIN_PY -m pip install --upgrade pip wheel setuptools + +echo "=== Installing build dependencies (Windows wheels via Wine pip) ===" +$WIN_PY -m pip install -r requirements-build.txt + +echo "=== Installing Chromium for Windows (inside Wine) ===" +export PLAYWRIGHT_BROWSERS_PATH=0 +$WIN_PY -m playwright install chromium + +echo "=== Running PyInstaller (Windows .exe) ===" +$WIN_PY -m PyInstaller --noconfirm --clean build/scribd_gui.spec + +DIST_DIR="/src/dist/Scribd PDF Downloader" +ZIP="/src/dist/Scribd-PDF-Downloader-Windows.zip" + +if [[ ! -d "$DIST_DIR" ]]; then + echo "ERROR: Expected output folder not found: $DIST_DIR" + ls -la /src/dist/ || true + exit 1 +fi + +cp -f /src/config.ini "$DIST_DIR/" 2>/dev/null || true +rm -f "$ZIP" +(cd /src/dist && zip -r "$(basename "$ZIP")" "Scribd PDF Downloader") + +echo "=== SUCCESS: $ZIP ===" +ls -lh "$ZIP" diff --git a/Scribd/build/docker/Dockerfile.cross-win b/Scribd/build/docker/Dockerfile.cross-win new file mode 100644 index 0000000..72f0a9f --- /dev/null +++ b/Scribd/build/docker/Dockerfile.cross-win @@ -0,0 +1,34 @@ +# Build Windows PyInstaller bundle from Linux using Wine + Windows Python. +# Used by: build/ci/docker-build-windows.sh + +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive +ENV WINEARCH=win64 +ENV WINEPREFIX=/root/.wine +ENV WINEDEBUG=-all + +RUN dpkg --add-architecture i386 \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + wine64 wine32 winbind \ + wget curl ca-certificates unzip zip \ + python3 python3-pip python3-venv \ + xvfb \ + && rm -rf /var/lib/apt/lists/* + +# Initialize Wine (needed for silent Python install) +RUN wineboot --init && sleep 10 || true + +# Install Windows Python 3.12 into the Wine prefix +RUN wget -q https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe -O /tmp/python-installer.exe \ + && wine64 /tmp/python-installer.exe /quiet InstallAllUsers=0 PrependPath=0 Include_pip=1 TargetDir=C:\\Python312 \ + && rm /tmp/python-installer.exe + +ENV WIN_PY="wine64 C:\\Python312\\python.exe" + +WORKDIR /src +COPY build/ci/docker-entrypoint-win.sh /docker-entrypoint-win.sh +RUN chmod +x /docker-entrypoint-win.sh + +ENTRYPOINT ["/docker-entrypoint-win.sh"]