Skip to content
Latchkey

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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →