CI: Electron-Build beschleunigt (~5min → ~2min)

- Custom Image electron-builder:latest (Mono + Docker CLI vorinstalliert)
- pull_policy: if-not-present (lokales Image, kein Registry-Pull)
- GitLab CI Cache für node_modules
- npm/Electron Cache-Verzeichnisse in /cache/
- npm ci --prefer-offline nutzt Cache wenn vorhanden
- before_script entfällt komplett (kein apt-get, kein curl)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-08 16:35:48 +01:00
parent 5b61cd5078
commit 68783ce040

View file

@ -69,7 +69,9 @@ docker-build:
electron-build: electron-build:
stage: deploy stage: deploy
image: electronuserland/builder:wine image:
name: electron-builder:latest
pull_policy: if-not-present
needs: [deploy] needs: [deploy]
rules: rules:
- if: $CI_COMMIT_BRANCH == "main" - if: $CI_COMMIT_BRANCH == "main"
@ -80,15 +82,21 @@ electron-build:
allow_failure: true allow_failure: true
variables: variables:
CONTAINER_NAME: "gaming-hub" CONTAINER_NAME: "gaming-hub"
before_script: ELECTRON_CACHE: "/cache/electron"
- apt-get update && apt-get install -y --no-install-recommends mono-devel && rm -rf /var/lib/apt/lists/* electron_config_cache: "/cache/electron"
- curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz | tar xzv --strip-components=1 -C /usr/local/bin docker/docker npm_config_cache: "/cache/npm"
cache:
key: electron-deps-${CI_COMMIT_REF_SLUG}
paths:
- electron/node_modules/
policy: pull-push
script: script:
- | - |
VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0") VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0")
echo "[Electron] Building v${VERSION} for Windows..." echo "[Electron] Building v${VERSION} for Windows..."
echo "[Electron] Wine: $(wine --version 2>/dev/null || echo 'not found')"
echo "[Electron] Mono: $(mono --version 2>/dev/null | head -1 || echo 'not found')" # Cache-Verzeichnisse sicherstellen
mkdir -p "$ELECTRON_CACHE" "$npm_config_cache"
cd electron cd electron
node -e " node -e "
@ -96,7 +104,9 @@ electron-build:
pkg.version = '${VERSION}'; pkg.version = '${VERSION}';
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
" "
npm ci --no-audit --no-fund
# npm ci mit Cache — prefer-offline nutzt Cache wenn vorhanden
npm ci --no-audit --no-fund --prefer-offline
npx electron-forge make --platform win32 --arch x64 npx electron-forge make --platform win32 --arch x64
# --- Deploy directly (no artifact upload needed) --- # --- Deploy directly (no artifact upload needed) ---