ci: cache pip wheels, npm deps, and embedded Python in release workflow
- Add pip and npm caching to build-windows and build-linux jobs - Cache embedded Python zip and Windows wheels across runs - Collapse per-dep pip download loop into a single resolver call First run after this lands populates the caches; subsequent release builds should drop from ~11min to ~3-5min.
This commit is contained in:
@@ -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: |
|
||||
|
||||
+19
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user