feat(install): verify release archive checksums in both installers

Merged
MD
5mo ago
+284-23

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 — generate checksums.txt (sha256sum *.tar.gz *.zip) and publish it as a release asset alongside the archives.
  • install (bash) — verify_checksum() fetches checksums.txt, looks up the archive's expected hash, and compares (sha256sum or shasum -a 256) before extracting.
  • install.ps1 — Test-Checksum fetches checksums.txt and compares Get-FileHash -Algorithm SHA256 before Expand-Archive. Replaces the deferral note from #930.
  • Behavior: hard-fail on mismatch; soft-skip (with a notice) when checksums.txt is absent (releases predating this change) or unreachable, so existing version-pinned installs keep working.
  • Tests — checksum-verification.test.ts asserts the release publishes the file and both installers fetch + compare + hard-fail on mismatch.

Verification

  • bash -n install clean; install.ps1 parses clean and the Pester suite (6/6) still passes on PowerShell 7.6.2.
  • TS: checksum-verification.test.ts green (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.txt for all archives.
    • Bash install and PowerShell install.ps1 fetch checksums.txt and verify before extraction; cross-platform SHA tools. PowerShell pins archive and checksums.txt to the same resolved tag to avoid a latest/ race.
  • Bug Fixes

    • PowerShell: decode Byte[] Invoke-WebRequest bodies on PS 5.1; ASCII-only so the script parses on Windows PowerShell 5.1.
    • Bash: derive checksums.txt from the archive URL; safe cleanup on checksum mismatch with guards against "." and "/".
    • Tests: added packages/opencode/test/install/checksum-verification.test.ts; updated packages/opencode/test/release-validation/windows-installer-930-codex.test.ts to assert shared $base URLs and that verification runs before Expand-Archive; Pester coverage for Test-Checksum (String/Byte[]/mismatch).

Summary by CodeRabbit

  • New Features

    • Release artifacts now include a generated SHA-256 checksums.txt to verify downloaded archives.
    • Bash installer validates the archive against checksums.txt before extraction, and fails fast on mismatches.
    • Windows installer validates the zip against checksums.txt before extraction, with improved handling for different checksum file encodings.
    • Installer downloads are now pinned to the same resolved release tag to prevent mixed assets.
  • 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.