107 lines
3.4 KiB
YAML
107 lines
3.4 KiB
YAML
# GitHub mirror — same logic as .gitea/workflows/build-scribd.yml
|
|
|
|
name: Build Scribd
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
paths:
|
|
- "Scribd/**"
|
|
- ".gitea/workflows/**"
|
|
- ".github/workflows/**"
|
|
pull_request:
|
|
branches: [main, master]
|
|
paths:
|
|
- "Scribd/**"
|
|
workflow_dispatch:
|
|
inputs:
|
|
build_linux:
|
|
description: "Build Linux — ubuntu-latest"
|
|
type: boolean
|
|
default: true
|
|
build_windows:
|
|
description: "Build Windows — windows-latest"
|
|
type: boolean
|
|
default: false
|
|
build_macos:
|
|
description: "Build macOS — macos-latest"
|
|
type: boolean
|
|
default: false
|
|
|
|
env:
|
|
SCRIBD_DIR: Scribd
|
|
PYTHON_VERSION: "3.12"
|
|
|
|
jobs:
|
|
plan:
|
|
name: Plan builds
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matrix: ${{ steps.plan.outputs.matrix }}
|
|
steps:
|
|
- id: plan
|
|
shell: bash
|
|
env:
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
BUILD_LINUX: ${{ github.event_name == 'workflow_dispatch' && inputs.build_linux || 'true' }}
|
|
BUILD_WINDOWS: ${{ github.event_name == 'workflow_dispatch' && inputs.build_windows || 'false' }}
|
|
BUILD_MACOS: ${{ github.event_name == 'workflow_dispatch' && inputs.build_macos || 'false' }}
|
|
run: |
|
|
python3 <<'PY'
|
|
import json, os
|
|
matrix = []
|
|
event = os.environ.get("EVENT_NAME", "")
|
|
def add(platform, runs_on, artifact):
|
|
matrix.append({"platform": platform, "runs-on": runs_on, "artifact": artifact})
|
|
if event in ("push", "pull_request"):
|
|
add("linux", "ubuntu-latest", "Scribd-PDF-Downloader-Linux.tar.gz")
|
|
else:
|
|
if os.environ.get("BUILD_LINUX", "true").lower() == "true":
|
|
add("linux", "ubuntu-latest", "Scribd-PDF-Downloader-Linux.tar.gz")
|
|
if os.environ.get("BUILD_WINDOWS", "false").lower() == "true":
|
|
add("windows", "windows-latest", "Scribd-PDF-Downloader-Windows.zip")
|
|
if os.environ.get("BUILD_MACOS", "false").lower() == "true":
|
|
add("macos", "macos-latest", "Scribd-PDF-Downloader-macOS.zip")
|
|
if not matrix:
|
|
raise SystemExit("No platforms selected.")
|
|
print("matrix=" + json.dumps(matrix))
|
|
PY
|
|
|
|
build:
|
|
name: Build (${{ matrix.platform }})
|
|
needs: plan
|
|
runs-on: ${{ matrix.runs-on }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include: ${{ fromJSON(needs.plan.outputs.matrix) }}
|
|
|
|
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: 14
|
|
if-no-files-found: error
|