Skip to content

Latest commit

 

History

History
242 lines (168 loc) · 28.3 KB

RELEASING.md

File metadata and controls

242 lines (168 loc) · 28.3 KB

Releasing

How to release, step by step. What is released and why it is done this way is decided in docs/releases.md.

Four things are released, each on its own:

What Where How
The implementation: @compmd/render, @compmd/processor, @compmd/sandbox, @compmd/registry, @compmd/devtools, @compmd/host, @compmd/vite, @compmd/pack, @compmd/create-pack, @compmd/blog, @compmd/create-blog, @compmd/lsp and its six @compmd/lsp-<os>-<cpu> (first published by hand, below) npm a tag v<version>; .github/workflows/release.yml publishes
The implementation: the crates compmd-markdown, compmd-pack, compmd-macros, compmd, compmd-host, compmd-project, compmd-components, compmd-lsp, tauri-plugin-compmd crates.io the same tag v<version>; the workflow publishes once the author approves its crates job
The language server's binaries, compmd-lsp-<version>-<target>, with SHA256SUMS the GitHub release v<version> the same tag; the workflow's last job, github-release
The packs, @comp-markdown/<pack> (Mermaid, wireframe, …) npm each its version in compmd-packs/versions.json; cargo make release-packs tags <pack>-v<version> and runs .github/workflows/release-packs.yml, which stages them
The spec the website, /spec/<version>/ a tag spec-v<version>, pushed with its commit on main; that push's Pages run deploys it

The website follows main and needs no release: every push that touches what it is built from deploys it.

The implementation

One version for the npm packages and the crate compmd, semantic, 0.x until the spec's version 1. compmd-markdown, the fork of markdown-rs, has a version of its own, raised only when its code changes.

0. Prerequisites

A release publishes only packages that npm and this repository's workflow already know. Before a package's first release, or after its trusted publisher changed, go through prerequisites, once per package: the package created on npm by a first version published by hand, trusted publishing set up for release.yml, the workflow publishing it, and each checked. Every package the workflow publishes has them, since 0.2.0.

1. Prepare

  • The prerequisites hold for every package the release publishes.
  • cargo make ci is green on main.
  • Each package's README says what changed, until the implementation has a changelog of its own.
  • The code implements the spec as it is on main, and SPEC_VERSION in crates/processor/src/lib.rs is the spec header's revision (**Version 1.0-draft.N.**), with npm-packages/wasm/src/index.ts and the READMEs the same (their tests say so). The workflow refuses a release otherwise.
  • The version, in one commit: npm-packages/render/package.json, npm-packages/wasm/package.json, npm-packages/sandbox/package.json, npm-packages/registry/package.json, npm-packages/devtools/package.json, npm-packages/host-js/package.json, npm-packages/vite/package.json, npm-packages/pack/package.json, npm-packages/create-pack/package.json, npm-packages/blog/package.json, npm-packages/create-blog/package.json, npm-packages/lsp/package.json (its platform packages take its version when the release writes them), crates/processor/Cargo.toml, crates/pack-types/Cargo.toml, crates/macros/Cargo.toml, crates/host/Cargo.toml, crates/project/Cargo.toml, crates/components/Cargo.toml, crates/lsp/Cargo.toml and crates/tauri/Cargo.toml, with the crates' dependencies on each other (version = … beside each path).
  • If the fork changed since its last release: its version in crates/markdown-rs/Cargo.toml (on its compmd branch), and the same version in the compmd-markdown dependency of crates/processor/Cargo.toml and crates/markdown-rs/mdast_util_to_markdown/Cargo.toml.
  • On Linux, once the version is committed: cargo make linux and cargo make linux site pass, so neither the release's checks nor its site deploy fail on the runner alone (CI, decision 12).
  • Push: the fork first, then this repository.

2. Tag, the workflow stages on npm, and the author approves

git tag v0.1.1
git push origin v0.1.1

The release workflow:

  1. checks the tag is the version in every package's package.json and in crates/processor/Cargo.toml, and that compmd::SPEC_VERSION is the spec header's revision;
  2. installs Playwright's WebKit, for the sandbox's, the registry's, the Vite plugin's, create-pack's and the blog's browser tests, and runs cargo make ci;
  3. packs the packages with pnpm, which writes the versions in place of their workspace:* dependencies on each other;
  4. stages them with npm's trusted publishing (npm stage publish): the renderer, then the processor, then the sandbox, which depends on both, then @compmd/host, which depends on none of them, then the registry, which needs the processor and @compmd/host (the registry rules' WebAssembly), then the Developer Tools, which depend on those four, then the Vite plugin, which depends on the first three and on @compmd/host, then @compmd/pack, which depends on all of those, then create-pack, whose packs pin it, then @compmd/blog, which depends on the processor, the renderer, the sandbox and the Vite plugin, then create-blog, whose blogs pin it, then @compmd/lsp; its six platform packages, which the build job writes from the lsp job's binaries (npm-packages/lsp/src/write-platforms.ts), are staged before all of them. No token is stored; each version carries its provenance. A version npm already has is left as it is, so a package whose first version was published by hand at the release's version is skipped, and a release that failed halfway can run again; a version it staged and nobody approved or rejected yet can't be staged again, so settle those first.

Two jobs, so the build never holds the token (audit S25). Steps 1 to 3 are the build job, which has no id-token: it runs every dependency's install and build scripts and the tests, so it never gets what proves to npm that it is this workflow. It uploads the tarballs, with order, the order to stage them in. Step 4 is the stage job, with id-token: write: it checks nothing out, installs nothing but npm, uses no cache, downloads the tarballs and stages them. A version counts as on npm when npm view <name>@<version> version prints that version. The packages are listed once, in PACKAGES at the top of release.yml, in the order above. release-packs.yml has the same two jobs.

A dry run of the release, before a tag: gh workflow run release.yml --ref main. It runs the Tauri check and the build job as a tag would, with the version of npm-packages/render/package.json as the release's, then npm publish --dry-run for each tarball in the stage job, so nothing is staged; the crates job doesn't run.

A staged version isn't installable until the author approves it, with two-factor authentication. cargo make approve-release does it: it lists what npm has staged of the @compmd/ packages as checkboxes, every version waiting for you chosen, and Enter approves the chosen ones in the order they were staged, so a package is never on npm before those it depends on, with one one-time code (npm asks for a new one when it expires; with a security key, press Enter at the code). --dry-run lists them and approves nothing. By hand, on npmjs.com, or (cd ~ && npm stage list --json) then (cd ~ && npm stage approve <stage-id>) for each, in that order. One that is wrong is rejected (npm stage reject <stage-id>) and its fix released as the next version.

Check, once each is approved:

curl -s https://registry.npmjs.org/-/package/@compmd%2frender/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fprocessor/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fsandbox/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fregistry/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fdevtools/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fhost/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fvite/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fpack/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fcreate-pack/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fblog/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2fcreate-blog/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2flsp/dist-tags
curl -s https://registry.npmjs.org/-/package/@compmd%2flsp-linux-x64/dist-tags

(and the same for the other five platform packages).

Each gives the new version as latest.

3. The crates: the author approves, the workflow publishes

Once the npm packages are staged, the workflow's second job, crates, waits in the GitHub environment crates-io for the author's approval: on the run's page on GitHub, Review deployments, then approve. crates.io has no staging, and a published crate version can't be deleted, only yanked, so this approval is the last look. The job then publishes with crates.io's trusted publishing (no token is stored; rust-lang/crates-io-auth-action gets one for the job and revokes it after):

  1. compmd-markdown, only when its version (crates/markdown-rs/Cargo.toml) isn't on crates.io yet, since compmd depends on it;
  2. compmd-pack, at the release's version, since compmd and compmd-host depend on it;
  3. compmd-macros, at the release's version, since compmd depends on it;
  4. compmd, at the release's version;
  5. compmd-host, at the release's version, since the plugin depends on it;
  6. compmd-project, compmd-components and compmd-lsp, at the release's version: the language server, after the crates it depends on;
  7. tauri-plugin-compmd, at the release's version. It brings no frames since 0.7.0 (an app embeds the bundle its own page's build writes), so its package is its code alone. It is published without cargo publish's build, which on Linux would need WebKitGTK: the Tauri check built and tested the same commit before the release went on.

A version crates.io already has is skipped, so a release that failed halfway can run again. The job runs .github/scripts/publish-crates.sh, which reads each crate's version with cargo metadata --no-deps, since the fork's checkout has no Cargo.lock, and stops before publishing anything when it can't read one. A crate's version counts as published only when crates.io answers 200, and as not published only on 404: any other answer stops it. It takes no argument but --dry-run, and refuses any other, a mistyped flag among them, before it does anything. Try it before a release, from the repository: .github/scripts/publish-crates.sh --dry-run packages what it would publish (cargo package --list, with the same flags, so it refuses what publishing would), and publishes nothing; the release job runs it too, before it stages the npm packages. In a fresh clone (git clone --recurse-submodules), the fork has no lock file, as on the runner. Check: cargo search compmd gives the new version. docs.rs builds the documentation a few minutes later.

0.4.0's job read the fork's version with cargo pkgid, which needs a lock file, got none, and stopped at compmd-markdown without publishing; compmd 0.4.0 was published by hand from the tag, as 0.3.0 was. 0.6.0's job published compmd, then cargo refused tauri-plugin-compmd: its frames, ignored by git, counted as uncommitted, and the dry run of then didn't package anything to show it. The plugin's 0.6.0 was published by hand from the tag.

Once, before the first release that publishes a crate this way (each step the author's):

  • On crates.io, each crate's Settings → Trusted Publishing → GitHub: the owner comp-markdown, the repository compmd, the workflow release.yml, the environment crates-io. For compmd, compmd-markdown, compmd-pack, compmd-macros, compmd-host, compmd-project, compmd-components, compmd-lsp and tauri-plugin-compmd: compmd-markdown's code is the fork's, but it is published from this repository's workflow.
  • On GitHub, the repository's Settings → Environments → crates-io: the author as its required reviewer, and only v[0-9]* tags allowed to deploy to it (not v*, which the extension's vscode-v… tags match too).

By hand, when the workflow can't (a crate's first version, which trusted publishing needs to exist): dry-run first, from the tag's commit, with cargo login once (a token with the publish-new and publish-update scopes, kept by the author):

git worktree add ../compmd-v0.4.0 v0.4.0 && git -C ../compmd-v0.4.0 submodule update --init
cargo publish --dry-run -p compmd --manifest-path ../compmd-v0.4.0/Cargo.toml
cargo publish -p compmd --manifest-path ../compmd-v0.4.0/Cargo.toml
rm -rf ../compmd-v0.4.0 && git worktree prune

Run them from this repository's root, where its tags are. Git won't remove a worktree with a submodule, even deinitialized (git worktree remove says working trees containing submodules cannot be moved or removed), so the last line deletes its folder and has git forget it.

compmd 0.3.0 was published so, on 2026-11-03, after its npm release, and 0.4.0 the same day: from the tag, so the crate is the same code as the packages.

A placeholder first, for a crate whose first version needs the release's packages, as tauri-plugin-compmd needs the sandbox's frames of the same version: a 0.0.0 with no code, published by hand from outside the repository (a Cargo.toml that says so, an empty lib.rs, a README pointing to the real versions, and the code's LICENSE, Apache 2.0; cargo publish --allow-dirty outside git). That creates the crate, so its trusted publisher can be set up, and the release workflow publishes its first real version. tauri-plugin-compmd 0.0.0 was published so on 2026-11-09, before 0.6.0. Yank the placeholder once the real version is out: cargo yank --version 0.0.0 tauri-plugin-compmd.

A new pack

A pack in compmd-packs/ is created on npm before its first release (releases, decision 8), by one command for any number of packs:

cargo make pack-placeholders --dry-run card chart   # what it would publish and set: nothing done
cargo make pack-placeholders card chart

For each pack npm doesn't have, it publishes a placeholder 0.0.0 (@comp-markdown/<pack>, with no code: a package.json that says so and names the pack's folder, a README pointing to the real versions, and the code's LICENSE, Apache 2.0), then sets its trusted publisher with npm trust github: the repository comp-markdown/compmd, the workflow release-packs.yml, staging only. A pack npm has is left as it is. It runs a pinned npm (11.21.1) from a folder outside the repository, in the terminal, so npm asks for the one-time code itself; npm's two-factor window covers about 80 packages, with the pause between packages that npm asks for.

A new trusted publisher that hasn't published in 2 days expires, so the pack's first release follows soon after. Deprecate each placeholder once its first version is out, so installs and the pack index skip it: cargo make deprecate-placeholders does it for every pack (or those named), 0.0.0 and the 0.0.0-… staging left, each pointing to the pack's first version, with --dry-run to see what it would run. It runs the pinned npm in the terminal, as pack-placeholders does, so npm asks for the one-time code itself.

The packs

Each pack in compmd-packs/ (@comp-markdown/mermaid, @comp-markdown/wireframe, and the first components) has a version of its own, written in one place, compmd-packs/versions.json (releases, decision 8). Its package.json and its document's export.version follow it: cargo make ci fails when they don't (cargo make pack-versions).

  1. Each release: the new versions in compmd-packs/versions.json, with what changed in each pack's README. Then:

    cargo make release-packs --dry-run   # what it would write and release: nothing done
    cargo make release-packs

    When a pack's files don't have its version yet, it writes them and stops: commit them, push, and run it again. It then lists every pack whose version npm doesn't have, and on your yes tags each <pack>-v<version> at main's commit, which must be pushed and match yours, pushes the tags, and runs release-packs.yml once (gh workflow run). The workflow runs cargo make ci once, then packs and stages every pack tagged at its commit whose version npm doesn't have, with trusted publishing, for you to approve (step 2). A run that stopped halfway can run again: a tag already at the commit is kept, and a version npm has is skipped.

  2. Approve them, once the workflow is green:

    cargo make approve-packs --dry-run   # what is staged, and what it would approve: nothing done
    cargo make approve-packs

    It lists what npm has staged of the packs as checkboxes, every version waiting for you chosen (space toggles one, a all), and Enter approves the chosen ones in the order they were staged, so a pack is never on npm before one staged before it. It asks for your one-time code once and passes it to each approval; npm asks for a new one when it expires. With a security key, press Enter at the code, and npm asks for it itself.

  3. Check: curl -s https://registry.npmjs.org/-/package/@comp-markdown%2f<pack>/dist-tags gives the new version as latest.

The Mermaid and wireframe packs' trusted publishers, once (with this workflow, 2026-11-20): each was set for a workflow of its own, release-mermaid.yml and release-wireframe.yml, which are gone. A package has one trusted publisher, whose workflow can't be changed, so each is revoked and set again, from outside the repository:

(cd ~ && npx npm@11.21.1 trust list @comp-markdown/mermaid)                  # its id
(cd ~ && npx npm@11.21.1 trust revoke @comp-markdown/mermaid --id=<id>)
(cd ~ && npx npm@11.21.1 trust github @comp-markdown/mermaid --file release-packs.yml --repository comp-markdown/compmd --allow-stage-publish --yes)

and the same for @comp-markdown/wireframe. A new trusted publisher that hasn't published in 2 days expires, so their next releases follow within 2 days, or the publisher is set again then.

The spec

  1. The spec's changelog says what the version holds, under ### Unreleased, and cargo make ci is green.

  2. Cut the release, then push it with its tag:

    cargo make spec-revision --release   # 1.0: the headers and the changelog's heading, a commit and the tag spec-v1.0
    git push --follow-tags
  3. The push of the commit to main runs the Pages workflow, which fetches every tag and deploys the site with the version at /spec/1.0/, frozen. The tag itself starts no run. /spec/ shows the latest release, and /spec/draft/ the draft.

A draft's revision (1.0-draft.N, spec §1), before a push of spec changes: their changelog entries are under ### Unreleased, then

cargo make spec-revision     # the next revision: headers, the changelog's heading, a commit and its tag
git push --follow-tags       # the commits and the revision's tag

CI's spec-revision job fails a push to main whose spec isn't its revision, as cargo make spec-check does. The Pages workflow runs on no tag: the push to main deploys the draft.

Prerequisites, once per package

Trusted publishing works only for a package that already exists on npm, so a new package is created by publishing its first version by hand, as @compmd/render and @compmd/processor were at 0.1.0, @compmd/sandbox, @compmd/registry, @compmd/vite, @compmd/pack and @compmd/create-pack at 0.2.0. A package can instead be created with a placeholder, as @compmd/devtools was before 0.3.0 (below). Then npm and the workflow are set up to publish it from then on. Each step is the author's, with their npm account; none is in the workflow.

npm, once for the scope:

  • The @compmd organization exists on npm, and the publishing account is a member that may publish to it.
  • The account has two-factor authentication on, for authorization and writes (below, "What publishing 0.1.0 taught").

The package's first version, by hand:

  1. Build and pack it, from the repository, with the version the other packages have:

    pnpm --dir sandbox build
    pnpm --dir sandbox pack --pack-destination ../packages
  2. Check the tarball before publishing: tar tzf for its files (dist/, for the Developer Tools its workers dist/worker.js and dist/views-worker.js beside dist/index.js, for the sandbox protocol.schema.json, for the Vite plugin client.d.ts and compmd.config.schema.json, for @compmd/pack tsconfig.pack.json, for create-pack template/, whose gitignore has no dot, for @compmd/blog theme/default.css), and tar xzf <file> -O package/LICENSE for its licence, which must be Apache 2.0; its package.json names the other packages' versions, not workspace:*.

  3. Try it without publishing, from outside the repository: (cd ~ && npm publish <path>/compmd-sandbox-<version>.tgz --access public --dry-run).

  4. Publish from outside the repository, after npm login. Dependencies go first: the renderer, then the processor, then the sandbox, then @compmd/host, then the registry, then the Developer Tools, then the Vite plugin, then @compmd/pack, then create-pack, then @compmd/blog, then create-blog.

    (cd ~ && npm publish <path>/compmd-sandbox-<version>.tgz --access public)
  5. Wait for npm's staging to end (below): the version is latest in curl -s https://registry.npmjs.org/-/package/@compmd%2fsandbox/dist-tags.

Trusted publishing, on npmjs.com:

  • the package's Settings → Trusted publisher → GitHub Actions;
  • the organization comp-markdown, the repository compmd, the workflow release.yml (for the packs, release-packs.yml), no environment;
  • allowed actions: npm stage publish alone, which npm always allows; not npm publish or npm dist-tag, so nothing the workflow does is installable before the author approves it;
  • a new trusted publisher must publish within 2 days or it expires. One made before 2026-05-20 allows npm publish alone; its allowed actions can be edited in its settings to staging alone, as @compmd/render's and @compmd/processor's were for 0.2.2. Its connection (the organization, the repository, the workflow, the environment) can't be edited: a wrong one is deleted and made again, as the Mermaid pack's was, made at first with release.yml instead of release-mermaid.yml. A workflow npm can't match to a trusted publisher fails with ENEEDAUTH … This command requires you to be logged in.

The workflow, in this repository:

  • release.yml lists it in PACKAGES, after the packages it depends on: its build job checks its version against the tag and packs it, and its stage job stages it;
  • it installs what the package's tests need (the sandbox's, the registry's, the Vite plugin's and create-pack's: Playwright's WebKit), as ci.yml does;
  • RELEASING.md lists it, in the table above and in the checks after a release.

Validated: npm checks the trusted publisher only at the workflow's first publish of the package. Once that release's workflow is green and the version approved, the version is latest in the registry (curl, as above), and the package's page on npmjs.com shows its provenance, from comp-markdown/compmd and release.yml. If its publish fails with the packages before it already published, fix the trusted publisher and run the workflow again: it skips the versions npm already has. A trusted publisher that doesn't allow what the workflow does fails with 403 … OIDC permission denied for this action: so 0.2.1 failed at the sandbox, whose publisher allowed staging while the workflow still ran npm publish.

A first version at a release's version. A new package depends on the others at the release's version, so its first version, by hand, is that version: publish the new packages by hand first, set up their trusted publishers, then push the tag. The workflow publishes the rest and skips the new ones. 0.2.0 went this way: @compmd/sandbox, @compmd/registry, @compmd/vite, @compmd/pack and @compmd/create-pack by hand, then v0.2.0 for @compmd/render and @compmd/processor. Until the tag's workflow has published them, the new packages don't install, so the two go together.

A placeholder first. A new package that needs what the release brings can't be published by hand ahead of it: @compmd/devtools needs the sandbox's observer, new in 0.3.0. So its first version was a placeholder, 0.0.0, with no code: a package.json that says so, a README pointing to the real versions, and the LICENSE of the time, MIT, published by hand from outside the repository. That created the package; its trusted publisher was set up; and v0.3.0 staged its first real version with the rest, with provenance. Deprecate the placeholder once the real version is out: (cd ~ && npm deprecate @compmd/devtools@0.0.0 "A placeholder with no code: install 0.3.0 or later").

The language server's packages go the same way, before the first release that publishes them: a placeholder 0.0.0 of @compmd/lsp and of each platform package (@compmd/lsp-darwin-arm64, -darwin-x64, -linux-arm64, -linux-x64, -win32-arm64, -win32-x64), each with its trusted publisher (release.yml, staging only), and on crates.io a placeholder 0.0.0 of compmd-project, compmd-components and compmd-lsp with theirs (docs/releases.md, decision 9).

cargo make release-placeholders <name>... creates them, as cargo make pack-placeholders creates packs, with --dry-run to see what it would do. For each @compmd/ package npm doesn't have, it publishes the placeholder from a folder outside the repository and sets its trusted publisher (npm trust github, release.yml, staging only), with one one-time code while it is valid. For each crate crates.io doesn't have, it publishes the placeholder crate with cargo publish (after cargo login, with a token that may publish new crates), then says how to set its trusted publisher on crates.io, which no command does. What a registry already has is left as it is, so it can run again. Then release within 2 days, before the trusted publishers expire:

cargo make release-placeholders @compmd/lsp @compmd/lsp-darwin-arm64 @compmd/lsp-darwin-x64 @compmd/lsp-linux-arm64 @compmd/lsp-linux-x64 @compmd/lsp-win32-arm64 @compmd/lsp-win32-x64 compmd-project compmd-components compmd-lsp

The grammars' packages are created the same way, by the same command, before the grammars' first release: tree-sitter-compmd on npm and on crates.io, and @compmd/lezer on npm. Their trusted publishers name the grammars' repository, comp-markdown/compmd-grammars, and its release.yml (on crates.io with its environment crates-io), and their placeholders its folders and its LICENSE; the grammars' README says how they are released.

cargo make release-placeholders tree-sitter-compmd @compmd/lezer

What publishing 0.1.0 taught

  • npm needs two-factor authentication to publish. Without it, npm publish fails with 403 … Two-factor authentication or granular access token with bypass 2fa enabled is required to publish packages, and nothing is uploaded. Turn on 2FA for authorization and writes (a security key, a passkey or an authenticator app), rather than a token that bypasses it.
  • npm stages a new package's first version. The registry first shows a placeholder, 0.0.0-stage, as latest, with "an operational version … is awaiting a staged release". The real version follows by itself: for 0.1.0, within about an hour, with nothing to approve. npm install fails until then, so publish packages that depend on each other together.
  • Each package has its own LICENSE. Without one, pnpm packs the repository's root LICENSE, which is the CC BY 4.0 licence of the spec's text, not the code's Apache 2.0.
  • npm doesn't run inside this repository. Its devEngines names pnpm, so npm stops with EBADDEVENGINES. Run npm from another folder (cd ~), and ask the registry with curl (as above) rather than npm view.
  • The crates go in order. compmd depends on compmd-markdown by path here and by version on crates.io, and crates.io rejects it until that version is published. The workflow publishes them in that order.