zip -0 to -9: Set the Compression Level
zip accepts a digit flag from -0 (store, no compression) to -9 (maximum compression).
The level is a speed-versus-size dial. CI artifacts that are already compressed gain little from -9, while text-heavy bundles can shrink noticeably.
What it does
The numeric flag sets the deflate compression level. -0 stores files without compressing them, -1 is fastest with the least compression, -6 is the default, and -9 spends the most CPU for the smallest output.
Common usage
# smallest archive, slowest
zip -9 -r build.zip dist
# fastest, store-only (good for already-compressed inputs)
zip -0 -r images.zip pngs
# default level
zip -r build.zip distOptions
| Flag | What it does |
|---|---|
| -0 | Store only, no compression |
| -1 | Fastest, least compression |
| -6 | Default compression level |
| -9 | Maximum compression, slowest |
| -r | Recurse into directories |
In CI
If the inputs are already compressed (PNGs, JPEGs, .gz, video), -9 burns CPU for almost no size gain; -0 or -1 finishes faster. For text, JSON, or JS bundles that compress well, -9 can meaningfully cut upload time and storage. Measure on your real artifact rather than always reaching for -9.
Common errors in CI
There is no error specific to the level, but choosing -9 on a large tree can dominate the job runtime. If a job is unexpectedly slow at the packaging step, check whether it is compressing already-compressed data at -9. Note that the GitHub Actions upload-artifact action does its own zipping, so adding -9 yourself before uploading double-compresses.