Skip to content

Release with the shared toolchain instead of a local copy - #59

Merged
stefanoverna merged 3 commits into
mainfrom
release-toolchain
Aug 31, 2026
Merged

Release with the shared toolchain instead of a local copy#59
stefanoverna merged 3 commits into
mainfrom
release-toolchain

Conversation

@stefanoverna

@stefanoverna stefanoverna commented Aug 31, 2026

Copy link
Copy Markdown
Member

toolchain/publish.mjs here was one of four 88–97% identical copies of the same
~280-line script, and this copy never got the fix that lets an interrupted
release resume (git merge-base --is-ancestor) — the exact scenario the script
exists for. It still fails with "have diverged. Pull (or push) first." on a
resumed release.

@datocms/release-toolchain is
that script, once, shared by all eleven DatoCMS repos that publish to npm, and
installed from its repository by git tag rather than published: the @datocms
scope on npm is what customers install, and internal automation does not belong
there.

What changed

  • toolchain/publish.mjs (–283 lines) → toolchain/release.mjs (+24), which is
    the User-Agent stamping and the rebuild it implies, and nothing else, passed as
    the shared script's one hook: beforeCommit, after changeset version and the
    lockfile refresh, after the publish plan is read, before
    git add -A && git commit.
  • publishrelease, publish-nextrelease:next (env prefix on the
    latter unchanged). Harmless in this repo, where the root package.json is
    private, but publish is a name npm runs itself during npm publish; the
    single-package repos migrating next would re-enter their own release script if
    they kept it.
  • @manypkg/get-packages dropped — the deleted script was its only consumer.
  • Docs updated in README.md, CLAUDE.md and .changeset/README.md.

Two behaviour changes, both deliberate

  1. The stamping moved after the publish plan is read. Safe: the plan is
    derived from the package.json versions changeset version has already
    written, and setClientVersion.ts only rewrites source. The rebuild still
    happens before the commit, so what is committed and what is published are
    built from the stamped source, exactly as before.
  2. The second npm install --package-lock-only is gone. The shared script
    already refreshes the lockfile right after changeset version, and nothing
    between the two touches a dependency.

A release moving packages to different versions also gets release: 4 packages
plus the tag list in the commit body instead of all of them in the subject — but
@datocms/* is a linked group, so in practice the subject stays
release: v5.9.0, or the package's own name when only one moved.

Two things the shared script adds

  • The tag is derived (vX.Y.Z when the repo is one package, name@version in a
    workspace) rather than hard-coded, and a step between changeset publish and
    git push checks that its derivation and changesets' agree — while the only
    thing that has happened is a publish.
  • The preflight prints the toolchain version, so a repo running a stale pin is
    visible in the release log.

https://claude.ai/code/session_01XaYAhzmiJwysZeq1XC5xrQ

Stefano Verna added 2 commits August 31, 2026 11:56
toolchain/publish.mjs here was one of four 88-97% identical copies of the
same script, and this copy never got the fix that lets an interrupted release
resume - the scenario the script exists for.

@datocms/release-toolchain is that script, once. What is left behind is
toolchain/release.mjs: the User-Agent version stamping and the rebuild it
implies, passed as the shared script's one hook.

The stamping now runs after the publish plan is read rather than before. That
is safe - the plan is derived from package.json versions changeset version
has already written, and setClientVersion.ts only rewrites source - and it
drops the second 'npm install --package-lock-only', which the shared script
already does right after the bump.

Claude-Session: https://claude.ai/code/session_01XaYAhzmiJwysZeq1XC5xrQ
Rehearsing the resume against a real registry and a real GitHub repo turned
up a bug that every copy of the old script had: killed between
'changeset publish' and 'git push', the next run reads an empty plan - the
packages are on the registry and their tags are local, which is all
changesets looks at - and aborts with 'there is nothing to release', leaving
the commit unpushed and no GitHub release. v1.1.0 finishes that release.

Claude-Session: https://claude.ai/code/session_01XaYAhzmiJwysZeq1XC5xrQ
@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

@datocms/cma-client

npm i https://pkg.pr.new/@datocms/cma-client@d0ad113

@datocms/cma-client-analysis

npm i https://pkg.pr.new/@datocms/cma-client-analysis@d0ad113

@datocms/cma-client-browser

npm i https://pkg.pr.new/@datocms/cma-client-browser@d0ad113

@datocms/cma-client-node

npm i https://pkg.pr.new/@datocms/cma-client-node@d0ad113

@datocms/cma-schema-types-generator

npm i https://pkg.pr.new/@datocms/cma-schema-types-generator@d0ad113

@datocms/dashboard-client

npm i https://pkg.pr.new/@datocms/dashboard-client@d0ad113

@datocms/rest-api-events

npm i https://pkg.pr.new/@datocms/rest-api-events@d0ad113

@datocms/rest-api-reference

npm i https://pkg.pr.new/@datocms/rest-api-reference@d0ad113

@datocms/rest-client-utils

npm i https://pkg.pr.new/@datocms/rest-client-utils@d0ad113

commit: d0ad113

v1.2.0 adds a guard a package runs from prepublishOnly to refuse a
hand-typed 'npm publish'. This repo does not use it: the root package.json is
private, so the same slip publishes nothing. The seven single-package repos
carry it, where 'npm publish' at the repo root does reach npm.

The lockfile is the substantive part of this commit. Changing the spec alone
left the previous SHA resolved, so 'npm ci' kept installing v1.0.0 while
package.json claimed otherwise.

Claude-Session: https://claude.ai/code/session_01XaYAhzmiJwysZeq1XC5xrQ
@stefanoverna
stefanoverna merged commit b083b3f into main Aug 31, 2026
4 checks passed
@stefanoverna
stefanoverna deleted the release-toolchain branch August 31, 2026 10:42
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.

1 participant