Skip to content

ci(node): add the npm release workflow - #16

Merged
mwaisaida-13 merged 7 commits into
release-2from
node/release-workflow
Sep 29, 2026
Merged

mwaisaida-13 merged 7 commits into
release-2from
node/release-workflow

Conversation

@mwaisaida-13

@mwaisaida-13 mwaisaida-13 commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds node-release.yml, which publishes the Node package to npm on a published
node-v* GitHub Release, following npm's
trusted publishing guide.

Flow: supported-version test matrix → verify and pack → publish from the npm
environment (OIDC, provenance) → post-publish smoke test.

Step Where
Matrix npm run list-supported-versions (existing)
Release gate npm run verify → node/scripts/verify.mjs: tag matches the version, private is off, CHANGELOG.md has the entry, repository.url is set, npm ≥ 11.5.1 on the publishing runner
Smoke test scripts/node_dev.py smoke: installs the exact published version into a temporary project, retrying 20 × 40 s for registry lag, and checks the public exports

package.json gains repository / homepage / bugs and publishConfig.access: public.
The publish job only runs in aws/developer-toolkit-elasticache, never in a fork.

Prerelease versions

npm refuses to publish a prerelease version without an explicit --tag, so verify
rejects any version with a prerelease suffix. Only X.Y.Z reaches npm publish. The
Python gate applies the same rule.

Verification

  • npm test: 103 passed; lint, format and typecheck clean.
  • verify on the current package stops at the "private": true guard.
  • The full flow, including OIDC publish with provenance and the smoke test, has been run
    end to end on a test package.

Before the first release

  1. Publish the first version manually (a trusted publisher can only be added to an
    existing package), by a member of the aws npm org.
  2. npmjs.com: add the trusted publisher (aws/developer-toolkit-elasticache,
    node-release.yml, environment npm) and allow npm publish.
  3. GitHub: create the npm environment with required reviewers.
  4. Release commit: remove "private": true, set the version, add the CHANGELOG entry.

mwaisaida-13 added 3 commits September 22, 2026 15:09
Mirrors python-release.yml: on a published node-v* GitHub Release, run the
supported-version test matrix, verify and pack, then publish from the `npm`
environment with OIDC trusted publishing and provenance, and smoke-test the
published package.

Release logic lives in scripts, not YAML:
- scripts/verify.mjs: tag matches package.json's version, `private` is off,
  CHANGELOG.md has an entry for the version, repository.url is set (provenance
  requires it), and optionally npm is new enough for trusted publishing. The
  publish job asserts the npm version instead of installing npm from the
  registry at publish time.
- scripts/smoke.mjs: install the published version into a temporary project
  with retries, import it, check the public exports and the installed version.

package.json gains repository/homepage/bugs (provenance verifies repository.url
against the publishing repository) and publishConfig.access=public, which a
scoped package needs on first publish.

Nothing publishes until a node-v* release is created, the `npm` GitHub
environment exists with required reviewers, and the npm trusted publisher is
configured for the package.
Node refuses to spawn .cmd shims directly (spawnSync npm.cmd EINVAL), which
failed the --require-npm check on the Windows CI runners.
Same shape as scripts/java_dev.py: a small stdlib-only Python script for the
step npm has no command for. The release gate stays in node/scripts/verify.mjs
(npm run verify, with its tests); everything else is plain npm in the workflow.

- smoke VERSION installs the exact published version into a temporary project
  and checks the public exports. It retries 20 times, 40s apart (about 13
  minutes), with a fresh npm cache and --prefer-online each time, logging
  'install attempt X/20 failed (registry may lag the upload)': the registry has
  taken around 8 minutes to serve a newly published tarball.
- Replaces node/scripts/smoke.mjs.
- The publish job gains a repository_owner guard, so a fork can never publish,
  and the build job packs into node/pack/ for the publish job.
@mwaisaida-13
mwaisaida-13 marked this pull request as ready for review September 24, 2026 19:36
python.yml watched scripts/**, so a change to another language's runner
(scripts/node_dev.py) also ran the Python matrix. Watch scripts/python_dev.py,
like java.yml watches scripts/java_dev.py.
Comment thread node/scripts/verify.mjs
Comment thread node/test/verify.test.ts
Comment thread node/test/verify.test.ts
Comment thread .github/workflows/node-release.yml
mwaisaida-13 added 3 commits September 24, 2026 23:47
verify.mjs:
- Accept X.Y.Z and X.Y.Z-rc.N only. Release candidates publish under the
  `next` dist-tag (verify writes dist_tag to GITHUB_OUTPUT and the publish
  step passes it), so `latest` keeps pointing at the last full release. Any
  other prerelease suffix is rejected in the gate; npm itself refuses a
  prerelease without an explicit --tag, which would only fail at the upload.
- Reject --require-npm without a value; it silently skipped the npm check.
- Reject non-numeric version parts instead of comparing NaN, which passed
  silently.

Tests: runVerify takes an env parameter; cases for each of the above.
verify accepts X.Y.Z and X.Y.ZrcN (PEP 440) and rejects any other suffix
(.devN, aN, bN). pip skips pre-releases unless one is requested explicitly, so
an RC on PyPI never reaches a plain pip install and needs no separate channel.
npm refuses to publish a prerelease version without an explicit dist-tag, so
verify.mjs now fails on any version with a prerelease suffix and the publish
step no longer needs a computed --tag. The Python gate applies the same rule
(X.Y.Z only). Prereleases are never required before a release.

@edlng edlng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm! :shipit:

@mwaisaida-13
mwaisaida-13 merged commit df69212 into release-2 Sep 29, 2026
21 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.

3 participants