ci: automate versioning and npm publishing via nx release - #7
Draft
BioPhoton wants to merge 3 commits into
Draft
Conversation
Add the release/publish workflow pair modelled on push-based/zod2nx-schema:
release.yml versions from conventional commits and pushes a v{version} tag as
the PushBased Bot App; publish.yml is triggered by that tag and publishes to
npm via OIDC trusted publishing (no NPM_TOKEN).
- pin .node-version to 24.19.0 (npm 11.17.0, needed for OIDC publishing) and
read it from ci.yml instead of hardcoding Node 20
- configure nx.json release: independent versioning scoped to cpu-prof,
v{version} tags, project changelogs with GitHub releases
- add publishConfig.access, repository, license, description to cpu-prof
- document the credential and implementation plans under docs/publishing
npm 11 fails `npm ci` when the lock omits optional platform variants, which the previous npm 10 lock did (darwin-arm64 only). Since CI now runs Node 24 / npm 11, install broke with 'Missing: @napi-rs/nice-linux-x64-gnu from lock file' and ~30 similar entries. Regenerated with npm 11.17.0: adds the full set of optional platform entries (16 @napi-rs/nice, 13 @parcel/watcher, 114 linux entries total). No dependency versions change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automates versioning and npm publishing, modelled on
push-based/zod2nx-schema.Merging triggers a real release. The npm trusted publisher is not configured yet (Plan 1 §C2), so today the result would be:
release.ymlsucceeds (version, changelog, tagv1.0.5, GitHub Release) and thenpublish.ymlfails on npm auth — leaving a tag and release with nothing published. Recoverable by re-running the job afterwards, no re-tag needed, but better avoided.Merge once
npm loginconfirms package ownership and the trusted publisher is set topush-based/cpu-prof/publish.yml/release.How it works
Two workflows joined by a tag: publishing is triggered by an immutable ref, so a failed publish is retried by re-running one job rather than re-versioning. No
NPM_TOKEN— npm trusted publishing over OIDC.Changes
.node-versionpinned to 24.19.0;ci.ymlreads it instead of hardcoding Node 20nx.json:releaseconfig (independent versioning scoped tocpu-prof,v{version}tags, project changelogs + GitHub releases) and annx-release-publishtarget defaultpackages/cpu-prof/package.json:publishConfig.access,repository,license,description,keywordsdocs/publishing/: the credential plan and the implementation planThree deliberate deviations from the reference repo
packageRoot: "{projectRoot}", not"{projectRoot}/dist". zod2nx builds with@nx/js:tscand publishesdist/as the package root; cpu-prof builds with rollup and itsmainis relative to the project root, withfiles: ["dist"]filtering. Copying the reference verbatim would ship entry points resolving todist/dist/….independentversioning, scoped tocpu-prof.fixedacrosspackages/*would dragnx-perf(0.0.1, never published) to1.0.5.createReleaseonprojectChangelogs, notworkspaceChangelog. The reference's placement is silently incompatible withindependent— Nx disables the workspace changelog and the GitHub Release with it. The first dry run hit exactly this.Also: Node 24 is required, not cosmetic — OIDC publishing needs npm ≥ 11.5.1, and Node 20 ships npm 10.x. Watch the patch level when bumping; Node 24.1.0 ships npm 11.3.0, still below the threshold.
Verification (local dry runs, nothing written)
nx release --dry-run→1.0.5, tagv1.0.5, GitHub Release previewednx release publish --dry-run→ correct target, registryregistry.npmjs.org, correctly refuses (v1.0.4already published)npm pack --dry-run→ 103 files / 34.6 kB; nosrc/,mocks/or*.tsbuildinfonx format:checkcleanExpect a patch bump: Nx scopes conventional-commit analysis to commits touching the released project, and only the
fix(lint)commit touchespackages/cpu-prof.Pre-existing defect worth deciding on separately
package.jsondeclares"main": "./dist/index.cjs"and arequirecondition, but the build emits ESM only — noindex.cjsexists, sorequire('@push-based/cpu-prof')fails. Not introduced here: the live1.0.4tarball has the same gap. Automation means shipping it every release, so either drop the CJS claims (the package is already"type": "module") or configure rollup for dual output. Left out of scope as a package-API call; documented indocs/publishing/02-implementation.md.