Skip to content

build: add an npm release command that builds and validates #113

Closed

Description

@hsd-bot

Why

Preparing a release takes two steps, building the files and then validating them (#113), and it's easy to skip the second. Publishing should also refuse to ship built files that don't pass.

What

  • npm run release builds the release files and validates them in place, leaving them ready to commit in the release PR. It doesn't tag or publish.
  • npm publish validates the committed built files first and refuses to publish if they fail. It doesn't rebuild, so what's published matches what's committed.
  • The release instructions (and chore(release): 2.0.0 #101) say to use npm run release.

Out of scope

  • Version bumping, tagging, and publishing (the maintainer does those by hand).
  • Changes to the build or to the validation itself.

Activity

  1. hsd-bot commented on Oct 30, 2026

    @hsd-bot
    CollaboratorAuthor

    hsd: Implementation plan

    • Add npm run test:release (script in make/release-check.js). It:
      1. Copies the files npm pack would publish into a gitignored .release/ directory and runs make/build.js there, so the repo's committed imagediff.js/imagediff.min.js are left untouched.
      2. Runs the existing Node specs (library, load and CLI specs) once against the fresh imagediff.js via require of the staged package (its main), and once against imagediff.min.js. The CLI spec runs the staged bin/imagediff.
      3. Runs the existing browser specs in Chromium with the page loading each built file as a plain <script> global.
      4. With --committed (for release PRs), also fails unless the repo's imagediff.js and imagediff.min.js match the fresh build byte for byte.
    • The specs pick their target from env vars (IMAGEDIFF_LIBRARY, IMAGEDIFF_BIN) and the spec page from a ?lib= query param, defaulting to the source, so npm test is unchanged.
    • Document it in the README and CONTRIBUTING (run before publishing), and point chore(release): 2.0.0 #101 at it.
  2. changed the title [-]test: smoke-test the built release files[/-] [+]build: add an npm release command that builds and validates[/+] on Oct 30, 2026
  3. hsd-bot commented on Oct 30, 2026

    @hsd-bot
    CollaboratorAuthor

    hsd: Implementation plan (rewritten ticket)

    PR #114 was closed unmerged, so the validation it added (pointing npm test at a built file with IMAGEDIFF_LIBRARY) isn't on master. I'll carry that forward unchanged and build the release commands on it:

    • npm run test:built runs npm test against imagediff.js and then imagediff.min.js, through require in Node and as a <script> global in the browser.
    • npm run release runs npm run build and then npm run test:built. It leaves the fresh files in place to commit, and doesn't tag or publish.
    • A prepublishOnly script refuses npm publish if the built files differ from what's committed (git diff against HEAD) and then runs npm run test:built. It doesn't rebuild.
    • Update the README and CONTRIBUTING release instructions to say to use npm run release. I can't edit chore(release): 2.0.0 #101 from here, so the PR will note the line it needs.

    This goes on a fresh branch from master, in a new PR, since #114 was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions