Releasing#
Vector ships three products, each at its own version:
packages/vector, published to the mirrorkinetis-dev/vector, which Packagist serves askinetis/vector;packages/vector-ui, published to npm as@kinetis/vector-ui;packages/vector-ai, published to the mirrorkinetis-dev/vector-ai, which Packagist serves askinetis/vector-ai(AI).
Beside them, the demo application, demo/ (The demo application), is released
the same way: it is published to the mirror
kinetis-dev/vector-demo,
which Packagist serves as the Composer project kinetis/vector-demo
(composer create-project --no-install kinetis/vector-demo vector).
Below, “product” covers it too.
Each Composer product has a mirror of its own, listed in MIRRORS in
scripts/release.mjs. The release plan refuses a product the manifest
lists with neither a mirror there nor npm, so adding a Composer product
means adding its mirror to MIRRORS in the same pull request.
packages.manifest.json at the repository root holds each product’s
version and is the one place it is decided. A product is bumped in the
pull request that changes it, and merging that pull request to main
releases it: .github/workflows/release.yml publishes every version the
manifest names that is not out yet. A release tags vX.Y.Z on the
product’s mirror, and <key>/vX.Y.Z on the vector-dev repository
itself at the released commit
(Monorepo tags and the docs catalogue).
Every rule is in scripts/version-policy.mjs,
scripts/validate-versions.mjs, scripts/bump.mjs and
scripts/release.mjs, tested by pnpm test:scripts.
Versions#
A version is X.Y.Z with no prerelease or build suffix, and no
component has a leading zero. A product moves exactly one step at a
time, on any major line, under scripts/version-policy.mjs:
Bump |
From |
To |
For |
|---|---|---|---|
|
|
|
a fix |
|
|
|
a new capability (on the |
|
|
|
a breaking change; |
Anything else is refused: a skipped number (0.23.2 to 1.0.1, or to
2.0.0), a major bump that keeps a minor or patch (0.23.2 to
1.1.0), and any move backwards (1.0.0 to 0.24.0).
One step at a time keeps every version reachable: since every version
that lands on main is published, a jump from 0.9.1 to 0.9.3 would
leave 0.9.2 unpublished while its changes ship inside 0.9.3.
A product’s version covers its own path, plus any directory its manifest
entry lists under includes. kinetis/vector includes
packages/vector-ui, because it pins the UI release it expects:
packages/vector/resources/ui.json is
{"package":"@kinetis/vector-ui","version":"X.Y.Z"}, the version in
packages/vector-ui/package.json. vector:install-ui installs that
release, and the admin warns when it runs another. A change to the UI
therefore releases kinetis/vector too, naming the new UI release.
kinetis/vector-demo includes packages/vector, packages/vector-ai
and packages/vector-ui: it releases on every release, and requires
the latest of each exactly.
demo/backend/composer.jsonrequireskinetis/vectorandkinetis/vector-aiat exactly their manifest versions, with no repository, so the published demo installs them from Packagist.demo/frontend/package.jsonrequires exactly the manifest’s@kinetis/vector-ui, the releasekinetis/vectorpins. In this repository pnpm links the workspace package for it (linkWorkspacePackages); the published demo gets it from npm.demo/backend/composer.monorepo.json, which only this repository’s stack reads (Working on Vector), requires the two path packages asdev-main as X.Y.0, each at its manifest’s minor version.
scripts/validate-versions.mjs checks all three, and bump.mjs moves
them, so the demo never names a release other than the one cut beside
it.
Bumping in the pull request#
A pull request that changes anything under packages/vector bumps
vector once. A pull request that changes anything under
packages/vector-ui bumps both products once, vector-ui for the npm
package and vector for the pin that names it:
node scripts/bump.mjs vector-ui minor
node scripts/bump.mjs vector patch
node scripts/bump.mjs vector-demo patch
A pull request that changes anything under packages/vector-ai bumps
vector-ai, and one that changes anything under demo/, or any
package, bumps vector-demo: the demo includes every package’s path,
so each package release is a demo release too.
Each bump is its own choice of patch, minor or major, with its own
CHANGELOG entry. bump.mjs prints the reminder to bump each product
that includes the one bumped (vector for vector-ui, vector-demo
for every package), but does not bump it for you.
One change needs no bump: a package.json under a product’s path whose
only difference is in devDependencies entries for the test and
type-check tooling TEST_ONLY_DEV_DEPENDENCIES in
scripts/version-policy.mjs lists (happy-dom, vitest,
@vue/test-utils, @nuxt/test-utils, @types/node and vue-tsc)
added, removed or moved to another range. None of them reaches the npm
package or the hosted bundle, so a Dependabot test-tooling update
(that group in .github/dependabot.yml lists the same packages) merges
without releasing either product. Anything else in that file counts as
usual: another field, any other devDependency (nuxt, vuetify,
vuetify-nuxt-module, sass-embedded and typescript shape the
bundle), one of these packages moving into dependencies or
peerDependencies, or a reordered field; a whitespace-only change is
exempt. So does any other file changed in the same pull request. A
product changed only that way may still be bumped, if you choose to
release it.
bump.mjs moves the product’s version in packages.manifest.json one
step. For vector-ui it also writes the version into
packages/vector-ui/package.json, into the pin,
packages/vector/resources/ui.json, into the demo’s
demo/frontend/package.json and into pnpm-lock.yaml’s specifier for
it. For vector and vector-ai it writes the version into the demo’s
demo/backend/composer.json, and on a minor or major bump moves the
dev-main as X.Y.0 alias in demo/backend/composer.monorepo.json
too, then prints the lock update that needs, run in the monorepo’s
stack:
docker compose exec app composer update kinetis/vector kinetis/vector-ai
kinetis/vector-ai requires kinetis/vector with a caret constraint,
which bump.mjs does not move. On the 0.x line ^0.Y admits only
0.Y.*, so a vector minor bump leaves it behind; from 1.0.0 on,
^X.Y admits every later X.* release, so only a vector major bump
does (1.0.0 needs ^1.0). When it is left behind, move it in
packages/vector-ai/composer.json in the same pull request, with a
vector-ai bump of its own, before updating the lock. A Composer product’s
composer.json has no version, and must not get one: Packagist reads it
from the mirror’s tag. It turns the product’s ## [Unreleased] CHANGELOG section into
## [X.Y.Z] - <today> under a fresh, empty ## [Unreleased]. It
refuses an empty Unreleased section, since that section becomes the
release’s notes. Write the CHANGELOG entry first, then bump.
A product needs one bump per pull request, whatever the number of
commits: the versions check measures the branch against its merge base
as one change. If another pull request bumped the same product first,
rebase onto main and bump again from its version.
The versions check#
.github/workflows/versions.yml runs
node scripts/validate-versions.mjs on every pull request and on every
push to main. Run it locally the same way. --base=<ref> names the
commit to compare against. Without it, the base is GITHUB_EVENT_BEFORE
when that is set, and HEAD^ otherwise.
Consistency, on the tree: every manifest version parses;
packages/vector-ui/package.jsoncarries the manifest’s name and version; each Composer product’scomposer.jsoncarries its name and no version; each product’s CHANGELOG has a## [<version>]section; each directory anincludeslists exists; andpackages/vector/resources/ui.jsonis exactly{"package":"@kinetis/vector-ui","version":"X.Y.Z"}, at the version inpackages/vector-ui/package.json; and the demo’s requirements are the manifest’s versions, exactly indemo/backend/composer.json(with no repository) anddemo/frontend/package.json, and asdev-main as X.Y.0indemo/backend/composer.monorepo.json, which otherwise matchescomposer.jsonbut for its repositories and scripts.History, against the base (the pull request’s merge base with its target, or what
mainpointed to before a push):a product with files changed under its path, or under a directory its
includeslists, has its version bumped (the failure names the included directory, so a UI-only change says whyvectorneeds a bump), except apackage.jsonchanged only in test-tooling devDependencies, as above;a version that moved, moved exactly one step;
a product with nothing changed keeps its version (an exempt
package.jsonchange counts as a change here, so it allows a bump).
The base and the head are compared end to end, so a version skipped across several commits fails even when each commit moved one step. With no base to compare against (the repository’s first commit, a branch’s first push, or a base that has no manifest yet), the history check is skipped, and the output says so.
Releasing on merge#
Each push to main runs the release:
Job |
Does |
|---|---|
Decide what this round publishes |
Reads the manifest, |
Wait for every required workflow on this commit |
Only when the round publishes something, and never on a rehearsal. Runs |
Publish @kinetis/vector-ui |
Only when |
Split and push the mirror |
One job per Composer product whose version is not on its mirror yet, one at a time in the manifest’s order ( |
Nothing is published before the gate passes. The required workflows are
ci.yml, versions.yml, monorepo-validate.yml, semgrep.yml,
infection.yml and sonarqube.yml, named by file in
REQUIRED_WORKFLOWS; release.yml itself and deploy-docs.yml are
excluded. Only a workflow’s push run on main at the release commit
counts: a pull request’s runs at the same commit do not. Each required
workflow passes on any successful run; a run still going keeps the gate
waiting; a cancelled, failed or skipped run fails it at once. A required
workflow with no run at all fails it at the deadline, so every required
workflow must run on any commit that bumps a version: infection.yml
runs on a push that changes packages.manifest.json for that reason.
The gate reads the runs with the job’s own token and actions: read;
pnpm test:scripts fails when a file in .github/workflows/ is neither
required nor excluded.
So a round goes out in the order its products depend on each other:
@kinetis/vector-ui to npm, then the kinetis/vector and
kinetis/vector-ai mirrors, then the kinetis/vector-demo mirror,
whose release requires exactly the versions published before it.
Packagist reads each mirror’s new tag through its webhook, usually
within a minute, so composer create-project kinetis/vector-demo of a
release made seconds ago can briefly fail to find the packages it
requires; it succeeds once Packagist has read the tags.
A push that changes no version publishes nothing and succeeds. npm goes
first, so a kinetis/vector tag never names a UI that cannot be
installed: a failed npm publish holds every mirror back. The mirror job
does not ask npm for the pinned release again, because the registry can
take minutes to serve a version it has accepted; a successful publish is
enough. A round with no UI release goes straight to the mirror.
The plan itself is all or nothing. Any refusal fails the whole round before anything is published, even when another product would have been releasable on its own: a refusal is an anomaly for a person to look at. The plan refuses to publish:
from a commit
origin/maindoes not contain, or from any ref butmain;a version whose CHANGELOG section is missing or empty, or whose
package.jsondisagrees with the manifest;a UI pin that is malformed or names another
@kinetis/vector-uiversion thanpackages/vector-ui/package.json;a product with neither a mirror in
MIRRORSnor npm, or a mirror that cannot be read (one not created yet, say);a version whose predecessor is not published. The version must be one step above the highest version already out. The exception is a product’s first release, when nothing is out yet.
Every npm release is latest: versions have no prerelease form, so no
dist-tag needs moving by hand. No
GitHub Release is created. The notes live in the CHANGELOGs, which ship with both packages, and on
the run’s summary page.
Rehearsing#
Under Actions → Release → Run workflow, run the workflow with dry run on, which is the default. It can run from any branch, so a pull request can be rehearsed before it merges. The rehearsal:
makes the same plan, reading the mirror anonymously;
builds the bundle and runs
npm pack --dry-runandnpm publish --dry-run;then splits each package it would publish, reads its mirror, and says what it would write there;
reads the monorepo tag of each product it would publish, and says which one it would push.
It writes nothing. Two refusals of a real run are reported instead of failing the rehearsal, so a branch can be rehearsed before it merges:
the commit is not on
origin/main;the mirror push’s source check fails (
origin’smaindoes not contain the commit, or the manifest there states another version).
Every other refusal fails a rehearsal as it fails a real run: a missing
predecessor, a package.json that disagrees with the manifest, a
missing or empty CHANGELOG section, or no manifest at the commit. A
dispatch with dry run off publishes like a push, but only when run from
main.
The mirror’s history#
A mirror’s main is the pure split, S, of its product’s path:
git subtree split --prefix=packages/vector of the released commit. A split is derived
from the monorepo’s own commits, metadata included, so the same source
always gives the same S. Each release’s S descends from the last one’s,
so main only ever fast-forwards. The tag vX.Y.Z points at that same
S. The hosted bundle is not in the mirrors: it ships in
@kinetis/vector-ui, which vector:install-ui downloads.
One-time setup#
GitHub (kinetis-dev/vector-dev).
Each mirror exists before the first release that names its product:
kinetis-dev/vector,kinetis-dev/vector-aiandkinetis-dev/vector-demo, public, created empty (no README, licence or.gitignore, so the first split lands as a fast-forward). The plan reads every mirror, so a missing one fails the whole round, not only its own product.The repository secret
RELEASE_DEPLOY_TOKENis one fine-grained personal access token with Contents: read and write on the mirrors,kinetis-dev/vector,kinetis-dev/vector-aiandkinetis-dev/vector-demo, and onkinetis-dev/vector-devitself for the monorepo tags, and nothing else. The workflow hands it, through a credential helper that is removed afterwards, as the password for the usernamex-access-token. Only three operations get it: the plan’s read of the mirrors’ tags, the writes to the mirrors, and the monorepo tag pushes.An environment named
npm-release, under Settings → Environments, with Deployment branches and tags limited to the branchmain.
npm (@kinetis/vector-ui). The package publishes through trusted
publishing alone: npm exchanges the workflow’s OIDC token for a
one-time credential, and no npm token is stored anywhere. The publisher
is configured on npmjs.com under the package’s Settings → Trusted
publishing:
A GitHub Actions publisher: organization
kinetis-dev, repositoryvector-dev, workflowrelease.yml, environmentnpm-release.Allow npm publish checked, since the workflow runs
npm publishdirectly; Allow npm dist-tag unchecked, since it never runsnpm dist-tag.Under Settings → Publishing access, Require two-factor authentication and disallow bypass 2fa tokens. Trusted publishing still works; a token cannot.
A trusted publisher can only be set up for a package that already exists on npm, so the first publish of a new package uses a short-lived granular token, which is revoked afterwards. Renaming the workflow file or the environment breaks publishing until the publisher on npm is updated to match. A new or changed publisher stays pending until a publish validates it, and lapses if none does by the date npm shows.
Packagist (kinetis/vector, kinetis/vector-ai, kinetis/vector-demo). For each Composer package, after its
mirror’s first release, so the repository has a composer.json to read:
Submit
https://github.com/kinetis-dev/vectoron packagist.org.On the mirror, add the GitHub webhook that Packagist’s Your profile → Show API Token page describes, so each push updates the package at once:
payload URL
https://packagist.org/api/github?username=<your username>;content type
application/json;the API token as the secret.
Recovery#
Re-running is safe; every step either finishes what is left or stops before writing.
The plan asks again what is published, so a re-run skips whatever an earlier attempt already got out.
A mirror is written in one atomic push of
mainand the tag. A rerun reads it first: amainalready at S and a tag already at S are left alone; a tag at any other commit fails the run, since two contents cannot both be one version and which one stands is for a person to decide.mainmoves only forward, under a lease naming themainit read. The push is refused iforigin’smainno longer contains the released commit (it was force-pushed past it), or if the manifest at that commit does not state the version being pushed. Amainthat has moved on to a newer version does not stop the push: the newer version needs this one published first.A failed mirror does not stop another product’s mirror after it: the mirror jobs run one at a time but do not fail fast. Re-run the failed mirror job; the others need nothing redone. Until it succeeds, a
kinetis/vector-demorelease published after it requires a version Packagist does not have, and itscreate-projectfails to resolve.The gate failed: fix
mainwith a new pull request. Its merge commit runs every workflow again and its release publishes the versions still not out. When the failure was transient, re-run the failed workflow on the release commit until it succeeds, then re-run the release’s failed jobs; the gate counts the re-run’s success.npm is skipped when the version is already published. If the npm job failed, the mirror jobs did not run; re-run the failed jobs.
A monorepo tag push that failed fails its job, after the mirror write or the npm publish it follows. Re-run the failed jobs of the same workflow run: the mirror job finds the mirror done, the npm job finds the version on npm, and each pushes the missing tag. A later push to
maindoes not repair it, and neither does Re-run all jobs: both plan again, find the version published and run no job for it. A tag at another commit fails the job on every attempt until a person removes or moves it.A release shown as cancelled while pending was replaced by a newer queued run before it started. Nothing is lost while the manifest still states that version, because the next run publishes it. If a later merge bumped the product again first, the next run refuses its version for a missing predecessor. Re-run the cancelled run, which publishes its own commit’s versions, then re-run the refused one. Do not dispatch a rehearsal while a release is running or queued: it can displace the pending release.
Prefer Re-run failed jobs: it keeps the jobs that succeeded, and their outputs, as they were. Once the mirror or npm has a version, publish a new version rather than changing it: neither Packagist nor npm lets one version change.
See also#
Working on Vector: the tests and checks a release passes.
Deployment: what
vector:install-uiand the bundle’s manifest guarantee.