diff --git a/.gitea/workflows/build-scribd.yml b/.gitea/workflows/build-scribd.yml new file mode 100644 index 0000000..c76d86e --- /dev/null +++ b/.gitea/workflows/build-scribd.yml @@ -0,0 +1,70 @@ +# Build Scribd PDF Downloader for Windows, macOS, and Linux. +# Requires Gitea Actions enabled + runners (see Scribd/BUILD.md#ci-builds). + +name: Build Scribd + +on: + push: + branches: [main, master] + paths: + - "Scribd/**" + - ".gitea/workflows/**" + - ".github/workflows/**" + pull_request: + branches: [main, master] + paths: + - "Scribd/**" + workflow_dispatch: + +env: + SCRIBD_DIR: Scribd + PYTHON_VERSION: "3.12" + +jobs: + build: + name: Build (${{ matrix.platform }}) + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + - platform: windows + runs-on: windows-latest + artifact: Scribd-PDF-Downloader-Windows.zip + - platform: macos + runs-on: macos-latest + artifact: Scribd-PDF-Downloader-macOS.zip + - platform: linux + runs-on: ubuntu-latest + artifact: Scribd-PDF-Downloader-Linux.tar.gz + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: pip + cache-dependency-path: ${{ env.SCRIBD_DIR }}/requirements-build.txt + + - name: Build (Windows) + if: matrix.platform == 'windows' + shell: pwsh + working-directory: ${{ env.SCRIBD_DIR }} + run: ./build/ci/build-windows.ps1 + + - name: Build (macOS / Linux) + if: matrix.platform != 'windows' + shell: bash + working-directory: ${{ env.SCRIBD_DIR }} + run: chmod +x ./build/ci/build-unix.sh && ./build/ci/build-unix.sh + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: scribd-${{ matrix.platform }} + path: ${{ env.SCRIBD_DIR }}/dist/${{ matrix.artifact }} + retention-days: 14 + if-no-files-found: error diff --git a/.gitea/workflows/release-scribd.yml b/.gitea/workflows/release-scribd.yml new file mode 100644 index 0000000..6217723 --- /dev/null +++ b/.gitea/workflows/release-scribd.yml @@ -0,0 +1,92 @@ +# Attach built Scribd artifacts to a Gitea Release (optional). +# Create tag v1.0.0 on main, then run workflow OR push the tag to trigger. +# +# Secret: add repo secret GITEA_TOKEN (write packages/releases) if auto token is insufficient. + +name: Release Scribd + +on: + push: + tags: + - "v*" + workflow_dispatch: + inputs: + tag: + description: "Release tag (e.g. v1.0.0)" + required: true + default: "v1.0.0" + +env: + SCRIBD_DIR: Scribd + PYTHON_VERSION: "3.12" + +jobs: + build: + name: Build (${{ matrix.platform }}) + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + - platform: windows + runs-on: windows-latest + artifact: Scribd-PDF-Downloader-Windows.zip + - platform: macos + runs-on: macos-latest + artifact: Scribd-PDF-Downloader-macOS.zip + - platform: linux + runs-on: ubuntu-latest + artifact: Scribd-PDF-Downloader-Linux.tar.gz + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: pip + cache-dependency-path: ${{ env.SCRIBD_DIR }}/requirements-build.txt + + - name: Build (Windows) + if: matrix.platform == 'windows' + shell: pwsh + working-directory: ${{ env.SCRIBD_DIR }} + run: ./build/ci/build-windows.ps1 + + - name: Build (macOS / Linux) + if: matrix.platform != 'windows' + shell: bash + working-directory: ${{ env.SCRIBD_DIR }} + run: chmod +x ./build/ci/build-unix.sh && ./build/ci/build-unix.sh + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: scribd-${{ matrix.platform }} + path: ${{ env.SCRIBD_DIR }}/dist/${{ matrix.artifact }} + retention-days: 30 + + release: + name: Create Gitea release + needs: build + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Prepare files + run: | + mkdir -p release-files + find artifacts -type f \( -name "*.zip" -o -name "*.tar.gz" \) -exec cp {} release-files/ \; + ls -la release-files/ + + - name: Publish Gitea release + uses: https://gitea.com/actions/gitea-release-action@v1 + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + with: + tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} + files: release-files/* diff --git a/.github/workflows/build-scribd.yml b/.github/workflows/build-scribd.yml new file mode 100644 index 0000000..bc9f232 --- /dev/null +++ b/.github/workflows/build-scribd.yml @@ -0,0 +1,70 @@ +# GitHub Actions mirror of .gitea/workflows/build-scribd.yml +# Kept in sync for hosts that only read .github/workflows/ + +name: Build Scribd + +on: + push: + branches: [main, master] + paths: + - "Scribd/**" + - ".gitea/workflows/**" + - ".github/workflows/**" + pull_request: + branches: [main, master] + paths: + - "Scribd/**" + workflow_dispatch: + +env: + SCRIBD_DIR: Scribd + PYTHON_VERSION: "3.12" + +jobs: + build: + name: Build (${{ matrix.platform }}) + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + - platform: windows + runs-on: windows-latest + artifact: Scribd-PDF-Downloader-Windows.zip + - platform: macos + runs-on: macos-latest + artifact: Scribd-PDF-Downloader-macOS.zip + - platform: linux + runs-on: ubuntu-latest + artifact: Scribd-PDF-Downloader-Linux.tar.gz + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: pip + cache-dependency-path: ${{ env.SCRIBD_DIR }}/requirements-build.txt + + - name: Build (Windows) + if: matrix.platform == 'windows' + shell: pwsh + working-directory: ${{ env.SCRIBD_DIR }} + run: ./build/ci/build-windows.ps1 + + - name: Build (macOS / Linux) + if: matrix.platform != 'windows' + shell: bash + working-directory: ${{ env.SCRIBD_DIR }} + run: chmod +x ./build/ci/build-unix.sh && ./build/ci/build-unix.sh + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: scribd-${{ matrix.platform }} + path: ${{ env.SCRIBD_DIR }}/dist/${{ matrix.artifact }} + retention-days: 14 + if-no-files-found: error diff --git a/GITEA.md b/GITEA.md index 0b43ab0..f2e3246 100644 --- a/GITEA.md +++ b/GITEA.md @@ -62,6 +62,19 @@ PDF-Downloaders/ --- +## CI builds (Actions) + +Workflows in `.gitea/workflows/` build **Windows, macOS, and Linux** packages on push to `main`. + +1. Enable **Actions** for the repo on git.masengr.com. +2. Ensure runners exist with labels `ubuntu-latest`, `windows-latest`, `macos-latest`. +3. Open **Actions → Build Scribd → Run workflow** (or push changes under `Scribd/`). +4. Download artifacts from the completed run. + +Details: [Scribd/BUILD.md](Scribd/BUILD.md#ci-builds-gitea--github-actions) + +--- + ## Clone on another machine ```bash diff --git a/README.md b/README.md index 27656b0..d22e03f 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,16 @@ Collection of tools to download documents as PDF files. Hosted on [Gitea](https://git.masengr.com/Michael-A-Sloan/PDF-Downloaders). +## CI builds + +**Actions** build Windows, macOS, and Linux packages automatically: + +- [.gitea/workflows/build-scribd.yml](.gitea/workflows/build-scribd.yml) — on every push to `main` +- Download **Artifacts** from the Actions tab after a green run +- Tag `v1.0.0` to trigger [release-scribd.yml](.gitea/workflows/release-scribd.yml) + +See [Scribd/BUILD.md](Scribd/BUILD.md#ci-builds-gitea--github-actions) for runner setup on your Gitea server. + ## Scribd See [Scribd/README.md](Scribd/README.md) for installation and usage. diff --git a/Scribd/BUILD.md b/Scribd/BUILD.md index e387c69..f3472da 100644 --- a/Scribd/BUILD.md +++ b/Scribd/BUILD.md @@ -6,8 +6,64 @@ You can ship **Scribd PDF Downloader** as a standalone app on Windows and macOS. |----------|--------|---------------| | Windows | `dist/Scribd PDF Downloader/Scribd PDF Downloader.exe` + zip | Windows PC | | macOS | `dist/Scribd PDF Downloader.app` + zip | MacBook Pro / any Mac | +| Linux | `dist/Scribd PDF Downloader/` + `.tar.gz` | Linux PC | -The app bundles **Python + Chromium** (~200–350 MB). No separate Python install is required on the target machine. +The app bundles **Python + Chromium** (~200–850 MB). No separate Python install is required on the target machine. + +--- + +## CI builds (Gitea / GitHub Actions) + +Automated builds for **Windows, macOS, and Linux** run from the repo root. + +| Workflow | Trigger | Output | +|----------|---------|--------| +| **Build Scribd** | Push to `main`, PR, or manual | Artifacts per OS | +| **Release Scribd** | Tag `v*` (e.g. `v1.0.0`) | Gitea Release with all zips | + +### Enable on Gitea (git.masengr.com) + +1. **Site admin:** enable **Actions** for the instance. +2. **Repo → Settings → Actions:** allow workflows. +3. Register **act runners** with labels: + - `ubuntu-latest` (Linux builds) + - `windows-latest` (Windows builds) + - `macos-latest` (macOS builds — requires a Mac runner) + + A single Linux runner will only build the **linux** job; Windows/macOS need matching runners or use GitHub Actions as a mirror. + +4. Open **Actions** tab → run **Build Scribd** manually (`workflow_dispatch`). + +Download artifacts from the completed workflow run. + +### Workflows (repo root) + +``` +.gitea/workflows/build-scribd.yml # main CI +.gitea/workflows/release-scribd.yml # tagged releases +.github/workflows/build-scribd.yml # GitHub mirror +``` + +CI scripts live in `Scribd/build/ci/` (`build-windows.ps1`, `build-unix.sh`). + +### Create a release + +```bash +git tag v1.0.0 +git push origin v1.0.0 +``` + +Optional: add repo secret **`GITEA_TOKEN`** (releases scope) for `release-scribd.yml`. + +### Artifact names + +| Artifact | File | +|----------|------| +| `scribd-windows` | `Scribd-PDF-Downloader-Windows.zip` | +| `scribd-macos` | `Scribd-PDF-Downloader-macOS.zip` | +| `scribd-linux` | `Scribd-PDF-Downloader-Linux.tar.gz` | + +> **Note:** Each archive is large (~500–900 MB) because Chromium is bundled. Hosted runners may hit artifact size limits; self-hosted runners avoid that. --- @@ -59,6 +115,26 @@ For distribution outside your Mac, use an **Apple Developer ID** certificate and --- +## Linux + +```bash +chmod +x build/ci/build-unix.sh +./build/ci/build-unix.sh +``` + +Output: `dist/Scribd-PDF-Downloader-Linux.tar.gz` + +Extract and run: + +```bash +tar -xzf dist/Scribd-PDF-Downloader-Linux.tar.gz -C dist +./dist/Scribd\ PDF\ Downloader/Scribd\ PDF\ Downloader +``` + +Requires a desktop environment (GUI uses tkinter). + +--- + ## Troubleshooting builds | Issue | Fix | diff --git a/Scribd/build/ci/build-unix.sh b/Scribd/build/ci/build-unix.sh new file mode 100644 index 0000000..d594772 --- /dev/null +++ b/Scribd/build/ci/build-unix.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# CI build script for macOS and Linux (Gitea/GitHub Actions). +set -euo pipefail + +echo "=== CI build: $(uname -s) ===" + +python -m pip install --upgrade pip +pip install -r requirements-build.txt + +export PLAYWRIGHT_BROWSERS_PATH=0 +playwright install chromium + +if [[ "$(uname)" == "Linux" ]]; then + sudo apt-get update + sudo apt-get install -y python3-tk tk-dev + sudo playwright install-deps chromium +fi + +pyinstaller --noconfirm --clean build/scribd_gui.spec + +if [[ "$(uname)" == "Darwin" ]]; then + APP="dist/Scribd PDF Downloader.app" + if [[ ! -d "$APP" ]]; then + echo "Error: $APP not found" + exit 1 + fi + codesign --force --deep --sign - "$APP" 2>/dev/null || true + rm -f "dist/Scribd-PDF-Downloader-macOS.zip" + ditto -c -k --sequesterRsrc --keepParent "$APP" "dist/Scribd-PDF-Downloader-macOS.zip" + echo "Created dist/Scribd-PDF-Downloader-macOS.zip" +else + DIR="dist/Scribd PDF Downloader" + if [[ ! -d "$DIR" ]]; then + echo "Error: $DIR not found" + exit 1 + fi + cp -f config.ini "$DIR/" 2>/dev/null || true + chmod +x "$DIR/Scribd PDF Downloader" 2>/dev/null || true + rm -f "dist/Scribd-PDF-Downloader-Linux.tar.gz" + tar -czf "dist/Scribd-PDF-Downloader-Linux.tar.gz" -C dist "Scribd PDF Downloader" + echo "Created dist/Scribd-PDF-Downloader-Linux.tar.gz" +fi diff --git a/Scribd/build/ci/build-windows.ps1 b/Scribd/build/ci/build-windows.ps1 new file mode 100644 index 0000000..1eb5ab8 --- /dev/null +++ b/Scribd/build/ci/build-windows.ps1 @@ -0,0 +1,25 @@ +# CI build script for Windows (used by Gitea/GitHub Actions). +$ErrorActionPreference = "Stop" + +Write-Host "=== CI build: Windows ===" -ForegroundColor Cyan + +python -m pip install --upgrade pip +pip install -r requirements-build.txt + +$env:PLAYWRIGHT_BROWSERS_PATH = "0" +playwright install chromium + +pyinstaller --noconfirm --clean "build\scribd_gui.spec" + +$Dist = "dist\Scribd PDF Downloader" +if (-not (Test-Path $Dist)) { + throw "Build output not found: $Dist" +} + +Copy-Item "config.ini" $Dist -Force -ErrorAction SilentlyContinue + +$Zip = "dist\Scribd-PDF-Downloader-Windows.zip" +if (Test-Path $Zip) { Remove-Item $Zip -Force } +Compress-Archive -Path $Dist -DestinationPath $Zip + +Write-Host "Created $Zip" -ForegroundColor Green