Skip to content

chore: make npm publish build dist and gate on the npm-publish environment#2

Merged
robrigo merged 1 commit into
mainfrom
chore/publish-readiness
Jul 16, 2026
Merged

chore: make npm publish build dist and gate on the npm-publish environment#2
robrigo merged 1 commit into
mainfrom
chore/publish-readiness

Conversation

@robrigo

@robrigo robrigo commented Jul 16, 2026

Copy link
Copy Markdown

Why

The deprecated prepublish hook does not run on npm publish or npm pack under modern npm, so a bare publish ships a tarball whose main and types point at a dist/ that was never built. Swapping it for prepack (build) and prepublishOnly (test) closes that gap. Compiled test specs were also riding along in dist as tarball bloat, so the tsconfig exclude drops them. The engines field and the README's Node line are updated to match the versions the CI matrix actually runs. A tag-triggered publish workflow is added, mirroring the shape used by the other SDK repos: it targets a required-reviewer npm-publish environment so a pushed tag queues for maintainer approval before npm ever issues a token, verifies the tag matches package.json's version, and publishes with provenance via OIDC.

Validation

yarn install --frozen-lockfile, yarn build, and yarn test all pass (35 tests). npm pack --dry-run with dist present shows no test spec files under dist/. Removing dist/ and re-running npm pack --dry-run rebuilds it via prepack, confirming dist/index.js and dist/index.d.ts land in the tarball.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the package publishing pipeline so npm pack / npm publish reliably ships a built dist/, reduces published artifacts by excluding compiled test specs from dist/, aligns documented/runtime Node requirements, and introduces a tag-triggered GitHub Actions publish workflow gated by the npm-publish environment.

Changes:

  • Update tsconfig.json excludes to prevent test/spec sources from being compiled into dist/.
  • Replace deprecated prepublish with prepack (build) + prepublishOnly (test) and add engines.node >= 20.
  • Add a tag-triggered Publish workflow that checks tag/version alignment and publishes with --provenance under an environment gate.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
tsconfig.json Excludes test/spec sources from the TypeScript compile output so dist/ doesn’t include compiled tests.
README.md Updates documented Node requirement to match current support expectations.
package.json Adds Node engine constraint and moves to prepack/prepublishOnly lifecycle hooks for correct publish/pack behavior.
.github/workflows/publish.yml Adds a gated, tag-triggered npm publish workflow with version verification and provenance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml
…nment

A bare npm publish ships a tarball whose main and types point at dist/index.js
and dist/index.d.ts, but the deprecated prepublish hook does not run on
npm publish or npm pack under modern npm, so a maintainer who tags and
publishes without a local dist/ around ships a broken package. Replacing it
with prepack (build) and prepublishOnly (test) restores that guarantee on
every pack and publish. The tsconfig exclude for spec files stops compiled
test specs riding along in dist as tarball bloat, and the engines field and
README pin the supported Node baseline to the versions CI actually runs
against. The publish workflow ties a pushed vX.Y.Z tag to a required-reviewer
npm-publish environment so the first and every subsequent publish needs
maintainer sign-off before npm ever sees a token.
@robrigo
robrigo force-pushed the chore/publish-readiness branch from 2ee4eda to fd89b8b Compare July 16, 2026 15:13
@robrigo
robrigo merged commit c358aa0 into main Jul 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants