Artifacts and release verification
An artifact is an output of a build, such as a package or report. It differs from a cache, which accelerates work and may be disposable. A release gate verifies required tests, expected artifact members, content and provenance before a separate authorized publishing step. A checksum detects changes relative to an expected digest, but a digest from the same untrusted source does not prove authenticity.
Repeatable packaging
Stable inputs, fixed tool versions, ordering, locale, timestamps and ownership metadata help make output reproducible. GNU tar can sort names and normalize timestamps and numeric ownership; gzip -n omits the original filename and timestamp. These options are implementation-specific. Build twice and compare bytes rather than claiming reproducibility based on flags. The fixture is a simple single-file archive with fixed modes, not proof across machines or versions. Never overwrite a known-good artifact before its candidate has passed verification. Keep staging separate, verify the exact file, and publish only after approval. Do not extract untrusted archives as part of a release check.
Record source revision, dependency identities, tool versions, test results and digest in a release manifest. A real release requires trusted signatures or attestations where appropriate, permissions, retention and rollback planning. The examples only generate and verify local synthetic artifacts; no upload, tag or deployment occurs. The modified-artifact example calculates a fresh digest successfully before asserting inequality. A missing file or unreadable artifact is an operational error, not evidence of differing bytes.
Practical examples
Run each example as a separate script in a fresh noninteractive Bash 5.2 process and empty practice directory. Tests use C locale; do not enter expected output as code. Git, GNU tar, gzip and coreutils are external dependencies for the relevant examples. Do not run these in an existing repository or CI workspace.
Build matching archives
mkdir src || exit 1printf 'app v1\n' > src/app.txt || exit 1chmod 644 src/app.txt || exit 1for name in first second; do tar --sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner -cf "$name.tar" -C src app.txt || exit 1 gzip -n -c "$name.tar" > "$name.tar.gz" || exit 1donecmp -s first.tar.gz second.tar.gz || exit 1printf 'same bytes\n' Expected stdout:
same bytesBoth builds use controlled metadata and identical input.
Detect modified bytes
printf 'verified\n' > artifact.txt || exit 1sha256sum artifact.txt > SHA256SUMS || exit 1sha256sum -c SHA256SUMS || exit 1printf 'modified\n' > artifact.txt || exit 1original=$(cat SHA256SUMS) || exit 1actual=$(sha256sum artifact.txt) || exit 1[[ $actual != "$original" ]] || exit 1printf 'rejected\n' Expected stdout:
artifact.txt: OKrejectedA known expected digest rejects modified bytes.
Plan without publishing
printf 'release candidate\n' > candidate.txt || exit 1sha256sum candidate.txt > candidate.sha || exit 1sha256sum --status -c candidate.sha || exit 1printf 'plan: candidate verified\n'printf 'plan: approval required\n'[[ ! -e published.txt && ! -L published.txt ]]Expected stdout:
plan: candidate verifiedplan: approval requiredVerification and authorization are separate; nothing is published.
Common mistakes
A matching checksum is not proof of publisher identity; a cache hit is not a release gate.
Practice
Build the same fixture twice and compare bytes; modify a copy and verify rejection. State which source must supply the trusted digest in a real release.
Next: Test aggregation and cleanup