zip Command Reference for CI Scripts
zip creates cross-platform .zip archives that any OS can open.
zip is preferred when an artifact must open on Windows or upload to a service that expects .zip (Lambda, many release pages). It is often missing from minimal Linux images.
Common flags/usage
- -r: recurse into directories
- -j / --junk-paths: store only filenames, dropping directory paths
- -q / --quiet: suppress output
- -x PATTERN: exclude matching files
- -9: maximum compression
Example
shell
cd dist
zip -r -q "../function-${GITHUB_SHA}.zip" . -x '*.git*'
cd -In CI
"zip: command not found" means a slim Debian/Alpine image; install zip unzip first. Forgetting -r on a directory leaves an empty or partial archive. For AWS Lambda the handler must sit at the archive root, so zip from inside the build dir, not its parent.
Key takeaways
- Pass -r to archive directories; without it zip skips them silently.
- Slim images omit zip, so install it or use tar instead.
- For Lambda, zip from inside the build dir so the handler is at the root.
Related guides
unzip Command Reference for CI Scriptsunzip extracts .zip archives in CI. Reference for -o, -d, -q, and -l, plus the interactive overwrite prompt t…
tar Command Reference for CI Scriptstar bundles and extracts archives in CI for caches and artifacts. Reference for -c, -x, -z, -C, and the compr…
gzip Command Reference for CI Scriptsgzip compresses single files with DEFLATE in CI. Reference for -d, -k, -c, and compression levels, plus the t…
find Command Reference for CI Scriptsfind walks directory trees and acts on matching files in CI. Reference for -name, -type, -exec, and -print0,…