diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 6011f1a..6ad9afa 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -105,6 +105,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: '20' + cache: 'npm' - name: Build frontend run: npm ci && npm run build @@ -112,6 +113,20 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.11' + cache: 'pip' + cache-dependency-path: pyproject.toml + + - name: Cache embedded Python + uses: actions/cache@v4 + with: + path: build/python-embed.zip + key: python-embed-3.11.9 + + - name: Cache Windows wheels + uses: actions/cache@v4 + with: + path: build/win-wheels + key: win-wheels-${{ hashFiles('build-dist-windows.sh', 'pyproject.toml') }} - name: Install build tools run: sudo apt-get update && sudo apt-get install -y --no-install-recommends nsis zip @@ -179,6 +194,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: '20' + cache: 'npm' - name: Build frontend run: npm ci && npm run build @@ -186,6 +202,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.11' + cache: 'pip' + cache-dependency-path: pyproject.toml - name: Build Linux distribution run: | diff --git a/build-dist-windows.sh b/build-dist-windows.sh index b585b6a..690a221 100644 --- a/build-dist-windows.sh +++ b/build-dist-windows.sh @@ -19,10 +19,15 @@ BUILD_OUTPUT="build/MediaServer-v${VERSION_CLEAN}-win-x64" clean_dist "${DIST_DIR}" "${WHEEL_DIR}" "${SITE_PACKAGES}" -# --- Download embedded Python --- -echo "Downloading embedded Python ${PYTHON_VERSION}..." -curl -sL "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-amd64.zip" \ - -o build/python-embed.zip +# --- Download embedded Python (cache-friendly) --- +mkdir -p build +if [ ! -f build/python-embed.zip ]; then + echo "Downloading embedded Python ${PYTHON_VERSION}..." + curl -sL "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-amd64.zip" \ + -o build/python-embed.zip +else + echo "Using cached embedded Python ${PYTHON_VERSION}" +fi unzip -qo build/python-embed.zip -d "${DIST_DIR}/python" # Patch ._pth to enable site-packages and app source @@ -64,15 +69,19 @@ VIS_DEPS=( ALL_DEPS=("${CORE_DEPS[@]}" "${WIN_DEPS[@]}" "${VIS_DEPS[@]}") -for dep in "${ALL_DEPS[@]}"; do - pip download --quiet --no-cache-dir --dest "$WHEEL_DIR" \ +# Reuse wheels from a previous cached run — only download if cache is empty +if [ -d "$WHEEL_DIR" ] && [ -n "$(ls -A "$WHEEL_DIR" 2>/dev/null)" ]; then + echo "Using cached wheels from $WHEEL_DIR" +else + # Single pip-download call — pip resolves all deps together, much faster than a loop + pip download --quiet --dest "$WHEEL_DIR" \ --platform win_amd64 --python-version "${PYTHON_SHORT}" \ --implementation cp --only-binary :all: \ - "$dep" 2>/dev/null || \ - pip download --quiet --no-cache-dir --dest "$WHEEL_DIR" \ + "${ALL_DEPS[@]}" 2>/dev/null || \ + pip download --quiet --dest "$WHEEL_DIR" \ --only-binary :all: \ - "$dep" -done + "${ALL_DEPS[@]}" +fi # Remove numpy 2.x wheels pulled as transitive deps (soundcard requires <2.0) for f in "$WHEEL_DIR"/numpy-2*; do