mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
ci: add zip packaging fallback (#4872)
ci: add python zip packaging fallback
This commit is contained in:
+25
-10
@@ -440,14 +440,6 @@ jobs:
|
|||||||
PACKAGE_NAME="${PACKAGE_BASENAME}-v${PACKAGE_VERSION}"
|
PACKAGE_NAME="${PACKAGE_BASENAME}-v${PACKAGE_VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create zip packages for all platforms
|
|
||||||
# Ensure zip is available
|
|
||||||
if ! command -v zip &> /dev/null; then
|
|
||||||
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
|
|
||||||
sudo apt-get update && sudo apt-get install -y zip
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd target/${{ matrix.target }}/release
|
cd target/${{ matrix.target }}/release
|
||||||
# Determine the binary name based on platform
|
# Determine the binary name based on platform
|
||||||
if [[ "${{ matrix.platform }}" == "windows" ]]; then
|
if [[ "${{ matrix.platform }}" == "windows" ]]; then
|
||||||
@@ -478,8 +470,31 @@ jobs:
|
|||||||
# Unix systems use zip command
|
# Unix systems use zip command
|
||||||
zip "$dst" "$src"
|
zip "$dst" "$src"
|
||||||
else
|
else
|
||||||
echo "❌ No zip utility available"
|
local python_bin="python3"
|
||||||
exit 1
|
if ! command -v "$python_bin" >/dev/null 2>&1; then
|
||||||
|
python_bin="python"
|
||||||
|
fi
|
||||||
|
if ! command -v "$python_bin" >/dev/null 2>&1; then
|
||||||
|
echo "❌ No zip utility or Python fallback available"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$python_bin" - "$src" "$dst" <<'PY'
|
||||||
|
import os
|
||||||
|
import stat
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
src, dst = sys.argv[1], sys.argv[2]
|
||||||
|
info = zipfile.ZipInfo(os.path.basename(src))
|
||||||
|
mode = os.stat(src).st_mode
|
||||||
|
info.external_attr = (mode & 0o777) << 16
|
||||||
|
if stat.S_ISREG(mode):
|
||||||
|
info.file_size = os.path.getsize(src)
|
||||||
|
|
||||||
|
with open(src, "rb") as source, zipfile.ZipFile(dst, "w", compression=zipfile.ZIP_DEFLATED) as archive:
|
||||||
|
archive.writestr(info, source.read())
|
||||||
|
PY
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user