fix: harden release script with clean build and verification - #37
Conversation
v0.8.8 was published with stale build artifacts (missing shouldSkipUpdate from PR #32). The release script built on top of old dist/ without cleaning first, and had no verification that artifacts reflected current source. Changes: - Clean dist/ before building to prevent stale artifacts - Add verify_build(): checks dist files exist, smoke tests module export, validates version consistency - Add verify_package_contents(): runs npm pack --dry-run to verify tarball includes required files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Good fix for the stale artifact problem. One bug to address before merging: Missing error handling on # Should be:
npm run clean || {
log_error "Clean failed, aborting release"
exit 1
}Minor: The |
There was a problem hiding this comment.
Pull request overview
This PR hardens scripts/release.sh to prevent publishing stale dist/ artifacts to npm by enforcing a clean build and adding post-build/package verification steps.
Changes:
- Run
npm run cleanbeforenpm run buildinbuild_and_test(). - Add
verify_build()to validate requireddist/outputs, smoke-test the built module export, and confirm version consistency. - Add
verify_package_contents()to ensurenpm pack --dry-runincludes required build artifacts before tagging/publishing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for f in "${required_in_pack[@]}"; do | ||
| if ! echo "$pack_output" | grep -q "$f"; then | ||
| log_error "npm pack missing required file: $f" | ||
| exit 1 |
There was a problem hiding this comment.
The grep -q "$f" check can produce false positives (e.g., dist/livetemplate-client.js will also match dist/livetemplate-client.js.map). This undermines the verification goal—consider matching the exact filename at end-of-line, using fixed-string matching, or parsing npm pack --dry-run --json output to reliably assert required files are included.
| log_info "Tests passed" | ||
|
|
||
| log_step "Cleaning previous build artifacts..." | ||
| npm run clean |
There was a problem hiding this comment.
npm run clean is not wrapped with the same error handling as tests/build. With set -e, a clean failure will abort the script without a clear log_error message; consider adding an explicit failure handler (similar to the npm test / npm run build blocks) so the release output is actionable.
| npm run clean | |
| npm run clean || { | |
| log_error "Clean failed, aborting release" | |
| exit 1 | |
| } |
- Add error handling for `npm run clean` with log_error on failure - Use `grep -qF "/$f"` for exact path matching in verify_package_contents to prevent false positives from substring matches (e.g., .js.map matching .js) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Review: looks good overall, one potential bug to check The clean-before-build and post-build verification approach is the right fix for the stale artifact problem. Potential bug in if ! echo "$pack_output" | grep -qF "/"; thenThe grep pattern has a leading This means the check will never match and will always fail, making if ! echo "$pack_output" | grep -qF "$f"; thenEverything else looks solid:
Suggest fixing the grep pattern before merging. |
npm pack --dry-run lists paths like "dist/foo.js" without a leading slash, so grep -qF "/dist/foo.js" would never match, blocking every release. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ReviewGood fix for the stale artifact problem. A few actionable items: Bug: Smoke test may fail for ESM output If package.json has "type": "module", the require() call in verify_build() will throw. Worth verifying the dist output is CJS before the v0.8.9 release run, or switching to --input-type=commonjs. Minor: npm run clean is a hard failure If clean is not defined in package.json scripts, the release aborts before building. Worth confirming this script is always present, or softening to a warning. npm pack --dry-run output parsing is fragile npm v6 and v7+ format this output differently. Since verify_build() already checks files exist on disk, verify_package_contents() only adds value for catching .npmignore/files misconfig. If that is the intent, inspecting an actual tarball (npm pack without --dry-run) is more reliable. |
Summary
shouldSkipUpdatefix from PR fix: skip patching focused form elements during DOM update #32 was missing from alldist/files in the published packagebuild_and_test()rannpm run buildon top of existingdist/without cleaning first, and no verification caught the stale artifactsscripts/release.shChanges to
scripts/release.sh:build_and_test()now runsnpm run cleanbeforenpm run buildverify_build()function: checks dist files exist and are non-empty, smoke tests the module export, validates version consistencyverify_package_contents()function: runsnpm pack --dry-runto verify the tarball includes required filesTest plan
bash -n scripts/release.sh— syntax check passesnpm test— all 278 tests passnpm run clean && npm run build— verifiedshouldSkipUpdatepresent in all dist/ files./scripts/release.shto publish v0.8.9 with correct artifacts🤖 Generated with Claude Code