feat(install): verify release archive checksums in both installers
Merged
MD
5mo ago+284+284+012345678901234567890123456789-23-23-01234567890123456789
What
Follow-up to #930 (raised in review by @coderabbitai and the consensus panel): publish a checksums file with releases and verify downloaded archives in both the curl/bash and PowerShell installers.
Stacked on feat/windows-powershell-installer (base of this PR) because install.ps1 only exists on that branch. Merge #930 first, then this — or rebase onto main after #930 lands.
Changes
.github/workflows/release.yml— generatechecksums.txt(sha256sum *.tar.gz *.zip) and publish it as a release asset alongside the archives.install(bash) —verify_checksum()fetcheschecksums.txt, looks up the archive's expected hash, and compares (sha256sumorshasum -a 256) before extracting.install.ps1—Test-Checksumfetcheschecksums.txtand comparesGet-FileHash -Algorithm SHA256beforeExpand-Archive. Replaces the deferral note from #930.- Behavior: hard-fail on mismatch; soft-skip (with a notice) when
checksums.txtis absent (releases predating this change) or unreachable, so existing version-pinned installs keep working. - Tests —
checksum-verification.test.tsasserts the release publishes the file and both installers fetch + compare + hard-fail on mismatch.
Verification
bash -n installclean;install.ps1parses clean and the Pester suite (6/6) still passes on PowerShell 7.6.2.- TS:
checksum-verification.test.tsgreen (57 pass across the install/branding set). - The mismatch/skip paths are content-asserted here and will get live exercise on the first release that ships
checksums.txt.
🤖 Generated with Claude Code
Summary by cubic
Adds SHA256 verification to both installers and ships a checksums.txt with each release. PowerShell pins the archive and checksum to the same tag; both installers hard-fail on mismatch and soft-skip when checksums are missing or unreachable.
-
New Features
- Release workflow generates and uploads
checksums.txtfor all archives. - Bash
installand PowerShellinstall.ps1fetchchecksums.txtand verify before extraction; cross-platform SHA tools. PowerShell pins archive andchecksums.txtto the same resolved tag to avoid a latest/ race.
- Release workflow generates and uploads
-
Bug Fixes
- PowerShell: decode Byte[]
Invoke-WebRequestbodies on PS 5.1; ASCII-only so the script parses on Windows PowerShell 5.1. - Bash: derive
checksums.txtfrom the archive URL; safe cleanup on checksum mismatch with guards against "." and "/". - Tests: added
packages/opencode/test/install/checksum-verification.test.ts; updatedpackages/opencode/test/release-validation/windows-installer-930-codex.test.tsto assert shared$baseURLs and that verification runs beforeExpand-Archive; Pester coverage forTest-Checksum(String/Byte[]/mismatch).
- PowerShell: decode Byte[]
Summary by CodeRabbit
-
New Features
- Release artifacts now include a generated SHA-256
checksums.txtto verify downloaded archives. - Bash installer validates the archive against
checksums.txtbefore extraction, and fails fast on mismatches. - Windows installer validates the zip against
checksums.txtbefore extraction, with improved handling for different checksum file encodings. - Installer downloads are now pinned to the same resolved release tag to prevent mixed assets.
- Release artifacts now include a generated SHA-256
-
Tests
- Added checks to ensure the release pipeline generates and uploads
checksums.txt. - Added automated coverage for checksum verification in both bash and PowerShell, including mismatch failures and Windows decoding behavior.
- Added checks to ensure the release pipeline generates and uploads