Skip to content
Latchkey

tar vs zip: Which to Use in CI

tar preserves Unix metadata and streams well; zip is self-indexed and ubiquitous on Windows. The right choice depends on the consumer.

Both formats archive a directory, but they make different tradeoffs. Picking the wrong one shows up as lost permissions or extra install steps.

What it does

tar concatenates files into a single stream, preserving Unix permissions, ownership, and symlinks, and is usually paired with gzip (.tar.gz). zip both archives and compresses per file and stores a central directory, so any single file can be read without scanning the whole archive. tar is the Unix default; zip is what Windows expects out of the box.

Common usage

Terminal
# tar.gz: preserves perms and symlinks, streams well
tar -czf build.tar.gz -C dist .
# zip: random access, Windows-friendly
zip -r build.zip dist

Choosing

NeedPrefer
Preserve Unix perms and ownershiptar
Preserve symlinks cleanlytar
Random access to one filezip
Windows recipients double-click extractzip
Stream over a pipe / networktar
AWS Lambda deployment packagezip (Lambda requires zip)

In CI

Prefer tar (.tar.gz) when the artifact stays in the Unix world and permissions or symlinks matter, since tar preserves them reliably and streams without a temp file. Prefer zip when a Windows user or a tool that expects zip is the consumer, or when the target requires it (AWS Lambda packages must be zip). For caching between Unix jobs, tar is the common choice.

Common errors in CI

Lost execute or permission bits after a round trip usually mean zip was built by a tool that does not store Unix permissions; tar avoids that. A Windows recipient who cannot open a .tar.gz simply lacks a tar tool; ship zip instead. Conversely, uploading a tar.gz where Lambda expects a zip fails because Lambda only accepts zip deployment packages.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →