Releasing#

Vector ships three products, each at its own version:

  • packages/vector, published to the mirror kinetis-dev/vector, which Packagist serves as kinetis/vector;

  • packages/vector-ui, published to npm as @kinetis/vector-ui;

  • packages/vector-ai, published to the mirror kinetis-dev/vector-ai, which Packagist serves as kinetis/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

patch

M.m.p

M.m.(p+1)

a fix

minor

M.m.p

M.(m+1).0

a new capability (on the 0.x line, a breaking change too)

major

M.m.p

(M+1).0.0

a breaking change; 0.23.2 to 1.0.0 leaves the 0.x line

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.json requires kinetis/vector and kinetis/vector-ai at exactly their manifest versions, with no repository, so the published demo installs them from Packagist.

  • demo/frontend/package.json requires exactly the manifest’s @kinetis/vector-ui, the release kinetis/vector pins. 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 as dev-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.json carries the manifest’s name and version; each Composer product’s composer.json carries its name and no version; each product’s CHANGELOG has a ## [<version>] section; each directory an includes lists exists; and packages/vector/resources/ui.json is exactly {"package":"@kinetis/vector-ui","version":"X.Y.Z"}, at the version in packages/vector-ui/package.json; and the demo’s requirements are the manifest’s versions, exactly in demo/backend/composer.json (with no repository) and demo/frontend/package.json, and as dev-main as X.Y.0 in demo/backend/composer.monorepo.json, which otherwise matches composer.json but for its repositories and scripts.

  • History, against the base (the pull request’s merge base with its target, or what main pointed to before a push):

    • a product with files changed under its path, or under a directory its includes lists, has its version bumped (the failure names the included directory, so a UI-only change says why vector needs a bump), except a package.json changed 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.json change 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, package.json, every CHANGELOG and the UI pin at the pushed commit and checks them again. Asks each Composer product’s mirror whether tag v<version> exists, and npm whether @kinetis/vector-ui@<version> exists. Puts each release’s notes, its CHANGELOG section, on the run’s summary page.

Wait for every required workflow on this commit

Only when the round publishes something, and never on a rehearsal. Runs scripts/release-gate.mjs, which polls this commit’s push runs on main every 20 seconds for up to 90 minutes, and fails as soon as a required workflow ends in anything but success.

Publish @kinetis/vector-ui

Only when @kinetis/vector-ui’s version is not on npm yet. Builds the hosted bundle into packages/vector-ui/dist/static with scripts/build-hosted-bundle.mjs --version=X.Y.Z, the package’s version, then runs npm publish --provenance --tag latest from packages/vector-ui, in the npm-release environment. The package’s prepack refuses a missing bundle or one built for another version. Then tags vector-ui/vX.Y.Z on vector-dev at the released commit, also when the version was already on npm.

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 (kinetis/vector first, which kinetis/vector-ai requires, then kinetis/vector-ai, then kinetis/vector-demo, which requires both), and only after the npm job succeeded or had nothing to do. Splits the product’s path and writes its mirror’s main and its vX.Y.Z tag, then tags <key>/vX.Y.Z on vector-dev at the released commit, also when the mirror already held the release. One mirror’s failure does not stop the next; re-run the failed job.

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/main does not contain, or from any ref but main;

  • a version whose CHANGELOG section is missing or empty, or whose package.json disagrees with the manifest;

  • a UI pin that is malformed or names another @kinetis/vector-ui version than packages/vector-ui/package.json;

  • a product with neither a mirror in MIRRORS nor 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-run and npm 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’s main does 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.

Monorepo tags and the docs catalogue#

Each release also tags kinetis-dev/vector-dev itself, with a lightweight tag <key>/vX.Y.Z. <key> is the product’s key in packages.manifest.json, its package name without the vendor: vector/v1.0.0, vector-ai/v1.0.0, vector-demo/v1.0.0, and vector-ui/v1.0.0 for the npm package. The tag points at the released monorepo commit, the one the split was made from, not at the split.

The tags let the Kinetis documentation server serve these docs as they stood for the version an application installed. It reads docs/ at the installed package’s tag, reads the catalogue at the tag of the package that owns each page, and falls back to main when a tag is missing.

A tag follows the same rule as a mirror’s tag. A tag already at the released commit is left alone. A tag at any other commit fails the job, and a person decides which commit stands. A missing tag is pushed with RELEASE_DEPLOY_TOKEN; the workflow’s own token stays read-only.

  • The mirror job tags its product after writing the mirror. It does so also when the mirror already held the release, so a re-run finishes a tag an earlier attempt missed.

  • The npm job tags vector-ui/vX.Y.Z after publishing, also when the version was already on npm.

A failed tag push is repaired by re-running the failed jobs of the same workflow run, not by a later push to main: that push’s plan finds the version published and runs no job for it. A tag push starts no workflow, since every workflow here runs on pushes to branches only.

docs/_extra/catalogue.json lists every page under docs/:

{
    "version": 1,
    "pages": [
        {
            "path": "ai/setup.md",
            "title": "Setup",
            "description": "Installing kinetis/vector-ai, the VECTOR_AI_* configuration, the AI settings and sealed provider keys.",
            "package": "kinetis/vector-ai"
        }
    ]
}
  • path is the page’s file, relative to docs/.

  • title is the page’s first heading.

  • description is one line saying what the page covers.

  • package is the Composer package that owns the page, whose tag the page is read at: kinetis/vector-ai for ai.md and ai/, kinetis/vector-demo for demo.md, and kinetis/vector for every other page. @kinetis/vector-ui owns none: an application gets the UI release kinetis/vector pins (resources/ui.json), so the installed kinetis/vector decides it, and the UI pages belong to that package.

scripts/validate-docs-catalogue.mjs, run by CI’s docs job, fails when a page is missing from the catalogue, an entry names a file that does not exist, a path is listed twice, a field is empty, a title is not the page’s first heading, version is not 1, or package is not a Composer product in packages.manifest.json. Sphinx copies docs/_extra/ to the site root unchanged (html_extra_path), so the catalogue is published beside llms.txt.

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-ai and kinetis-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_TOKEN is one fine-grained personal access token with Contents: read and write on the mirrors, kinetis-dev/vector, kinetis-dev/vector-ai and kinetis-dev/vector-demo, and on kinetis-dev/vector-dev itself for the monorepo tags, and nothing else. The workflow hands it, through a credential helper that is removed afterwards, as the password for the username x-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 branch main.

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, repository vector-dev, workflow release.yml, environment npm-release.

  • Allow npm publish checked, since the workflow runs npm publish directly; Allow npm dist-tag unchecked, since it never runs npm 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:

  1. Submit https://github.com/kinetis-dev/vector on packagist.org.

  2. 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 main and the tag. A rerun reads it first: a main already 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. main moves only forward, under a lease naming the main it read. The push is refused if origin’s main no 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. A main that 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-demo release published after it requires a version Packagist does not have, and its create-project fails to resolve.

  • The gate failed: fix main with 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 main does 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#