Skip to content

Releasing

This is how a Parsec release goes out, from an empty registry to cargo add parsec-web. Most of it happens once, before 0.1.0; after that, a release is a version bump, a changelog entry and a signed tag.

Every command runs from your home folder as written. Paths are absolute and gh gets --repo, so nothing depends on where your shell is.

Where Name What it is
crates.io parsec-web The crate people depend on. use parsec::..., with encoding, url and xpath on by default and css off.
crates.io parsec-web-core The parser, selectors and DOM.
crates.io parsec-web-encoding, parsec-url, parsec-xpath, parsec-web-css, parsec-base, parsec-js, parsec-xml The modules behind the features.
PyPI parsec-web Wheels for CPython 3.9 to 3.15, free-threaded too, and an sdist.
npm parsec-web The WebAssembly build, for browsers and Node.
GitHub release parsec-capi-VERSION-TARGET.tar.gz / .zip The C library, header, pkg-config and CMake files, for five targets.

The C API isn’t on crates.io: it’s a C library, and its users want the built .so, .dylib or .dll, not a Rust crate.

Why six crates and not one? The modules all depend on the parser, so the parser can’t depend on them, and it can’t carry the re-exports either. parsec-web is a thin crate on top that re-exports the lot.

Pushing a signed v* tag starts four workflows at once:

  • release.yml checks the tag’s signature against .github/allowed_signers on main, and that Cargo.toml’s version is the tag’s. It runs the gates, and nothing is built until they pass. It packages all six crates twice from fresh checkouts, fails if the two differ by a byte, attests them and makes the GitHub release. Then, if CRATES_PUBLISH is true, its crates-io job publishes them in dependency order and checks each one’s checksum on crates.io against the attested package.
  • release-python.yml builds the wheels and the sdist, waits for that GitHub release, then publishes to PyPI if PYPI_PUBLISH is true.
  • release-npm.yml builds and tests the package, waits for the release, then publishes to npm if NPM_PUBLISH is true.
  • release-capi.yml builds the C packages, waits for the release, then attests them and attaches them to it.

No release, no publishing: a tag with a bad signature, the wrong version or a failed gate stops before the build, and the other three time out waiting after 30 minutes without publishing anything. All three publish jobs run in the release environment and use trusted publishing, so no registry token is stored in GitHub. Each one skips a version that’s already up, so a failed run can be run again.

release.yml runs three gates beside the tag check, and its build job waits for its gates job, which passes only when all three did. A manual run of release.yml runs them too.

Job Fails the release when
conformance Any suite in conformance/baseline.json passes fewer cases or fails more than the last release did, or writes no counts at all, or writes counts the gate can’t read (a missing number, or a file that isn’t JSON). cargo test --workspace failing fails it too.
boss The final boss (-- boss --gate: all 1,000 pages, once, through Parsec and html5ever) crashes, passes 10 s on a page, leaves a page without a document, or builds a different number of elements in Parsec and html5ever on any page.
fuzz Five minutes of cargo fuzz run on any target in crates/*/fuzz finds a crash. Every target runs at once, one job each; whatever it found is kept as the job’s artifact.

The same comparison against the baseline runs on every pull request as CI’s conformance job. It isn’t a required check, but a drop shows red on the pull request that made it, not on release day. To run it on your machine:

Terminal window
cd ~/Documents/GitHub/parsec
CONFORMANCE_DIR=target/conformance cargo test --workspace
scripts/conformance-gate.sh conformance/baseline.json target/conformance

conformance/baseline.json is each suite’s passed, failed and skipped at the last release. It changes only in a release pull request (step 2 of Every release), never to make another pull request pass. A pull request that trades a case away says so, and the release pull request takes the new counts in on purpose.

A suite that’s new since the last release has counts but no entry yet. The gate lists it as new and doesn’t hold it to anything; the release pull request adds it, and from then on it’s gated like the rest. test262 (from parsec-js) and the W3C XML suite (from parsec-xml) come in this way when their pull requests land.

CI runners are too noisy to time on, so speed isn’t a gate in the workflow. Before tagging, run the benchmark against the previous tag on a quiet machine, with the one-minute load average under 3:

Terminal window
uptime # the first of the three load averages: under 3
git -C ~/Documents/GitHub/parsec worktree add "$HOME/parsec-prev" v0.1.0 # the previous tag
cargo run --release --manifest-path "$HOME/parsec-prev/bench/Cargo.toml" > "$HOME/bench-prev.txt"
cargo run --release --manifest-path ~/Documents/GitHub/parsec/bench/Cargo.toml > "$HOME/bench-now.txt"
diff "$HOME/bench-prev.txt" "$HOME/bench-now.txt"
git -C ~/Documents/GitHub/parsec worktree remove "$HOME/parsec-prev"

Any page or table that’s more than 5% slower than at the previous tag is explained in the release notes: what got slower, and why it’s worth it. If you can’t explain it, it’s a bug to fix before the release.

From 0.3.0, Parsec publishes as parsec-web (#213). parsec-html, parsec-html-core, parsec-html-css and parsec-html-encoding become parsec-web, parsec-web-core, parsec-web-css and parsec-web-encoding. Every other crate keeps its name. The registries know nothing about the new names yet, so do these once before tagging v0.3.0. The npm step has the same 2-day deadline as before.

crates.io. Every new name already has a 0.0.0 placeholder, and so do parsec-base, parsec-js and parsec-xml, which 0.3.0 publishes for the first time. Give each of the seven the trusted publisher from step 3 below, with the same fields: GitHub, parsec-html, parsec, release.yml, release. parsec-web · parsec-web-core · parsec-web-css · parsec-web-encoding · parsec-base · parsec-js · parsec-xml

Terminal window
for c in parsec-web parsec-web-core parsec-web-css parsec-web-encoding parsec-base parsec-js parsec-xml; do
cargo owner --add foothillsdigital "$c" # a token with the change-owners scope
done

PyPI. Add a pending publisher, as in step 4, with PyPI Project Name parsec-web, Owner parsec-html, Repository name parsec, Workflow name release-python.yml and Environment name release. Done on 25 November 2026.

npm. Nine packages need to exist first: parsec-web and the eight native builds in the @parsec-web scope. Make sure the parsec-web npm organization exists, then publish the placeholders. npm asks for your 2FA code each time:

Terminal window
names="parsec-web @parsec-web/binding-linux-x64-gnu @parsec-web/binding-linux-arm64-gnu @parsec-web/binding-linux-x64-musl @parsec-web/binding-linux-arm64-musl @parsec-web/binding-darwin-x64 @parsec-web/binding-darwin-arm64 @parsec-web/binding-win32-x64-msvc @parsec-web/binding-win32-arm64-msvc"
npm login
for name in $names; do
d=$(mktemp -d)
printf '{"name":"%s","version":"0.0.0","description":"Reserved for Parsec (github.com/parsec-html/parsec). The first release comes with Parsec 0.3.0.","license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/parsec-html/parsec.git"}}\n' "$name" > "$d/package.json"
npm publish "$d" --access public || break
rm -rf "$d"
done

On the day you tag, trust the workflow for all nine. Use npm 11.15 or newer:

Terminal window
for name in $names; do
npm trust github "$name" --file release-npm.yml --repo parsec-html/parsec --env release --allow-publish
done

After 0.3.0 is out:

  • Release the last parsec-html 0.2.x patch from the parsec-html-0.2-pointer branch. It changes no code. Its descriptions, READMEs and changelog point to parsec-web.
  • Run npm deprecate parsec-html "Parsec is parsec-web from 0.3.0: npm install parsec-web".
  • Yank the new names’ 0.0.0 placeholders and deprecate the npm ones, as in After the release.

Everything from here to Every release is how 0.1.0 went out under the old names. It’s kept as the record, and for the steps that don’t change.

Do these once. The trusted-publisher steps have a deadline on npm (see step 5), so take them in this order, with the npm one on the day you tag.

Only v* tags can deploy to it:

Terminal window
gh api -X PUT repos/parsec-html/parsec/environments/release \
-F "deployment_branch_policy[protected_branches]=false" \
-F "deployment_branch_policy[custom_branch_policies]=true"
gh api -X POST repos/parsec-html/parsec/environments/release/deployment-branch-policies \
-f name='v*' -f type=tag

To have a second maintainer approve each publish as well, add a required reviewer under Settings → Environments → release.

crates.io won’t let trusted publishing create a crate: the first version of each has to come from an API token. parsec-html already has its 0.0.0 placeholder (published 18 November 2026). The other five need the same, so that 0.1.0 of every crate comes from the release workflow, attested and checked.

Make a token at crates.io/settings/tokens/new: name parsec placeholders, expiry 1 day, scope publish-new only, crates parsec-*. Then:

Terminal window
cargo login # paste the token
for c in parsec-html-core parsec-html-encoding parsec-url parsec-xpath parsec-html-css; do
curl -sf -o /dev/null -A "parsec-html release" "https://crates.io/api/v1/crates/$c" && continue # there already
d="$HOME/parsec-placeholders/$c"
mkdir -p "$d/src" && : > "$d/src/lib.rs"
printf '[package]\nname = "%s"\nversion = "0.0.0"\nedition = "2024"\nlicense = "Apache-2.0"\ndescription = "A placeholder for part of Parsec, the HTML toolkit. Use parsec-html."\nrepository = "https://github.com/parsec-html/parsec"\n' "$c" > "$d/Cargo.toml"
cargo publish --manifest-path "$d/Cargo.toml" --allow-dirty || break
done
cargo logout
rm -rf "$HOME/parsec-placeholders"

Then revoke the token on the same page. crates.io limits how fast new crates can be made. If one is refused as too many, the loop stops there: wait as long as the error says, cargo login again and rerun it, and it skips the crates already up.

To give the other maintainer the same rights on every crate:

Terminal window
for c in parsec-html parsec-html-core parsec-html-encoding parsec-url parsec-xpath parsec-html-css; do
cargo owner --add foothillsdigital "$c"
done

(That needs a token with the change-owners scope; each invite has to be accepted on crates.io.)

3. Add the trusted publisher on crates.io, for each crate

Section titled “3. Add the trusted publisher on crates.io, for each crate”

For each of parsec-html, parsec-html-core, parsec-html-encoding, parsec-url, parsec-xpath and parsec-html-css, open https://crates.io/crates/NAME/settings, choose Add under Trusted Publishing, and fill in:

Field Value
Publisher GitHub
Repository owner parsec-html
Repository name parsec
Workflow filename release.yml
Environment release

The direct links: parsec-html · parsec-html-core · parsec-html-encoding · parsec-url · parsec-xpath · parsec-html-css

One token from the workflow covers every crate set up this way.

parsec-html doesn’t exist on PyPI yet, so this is a pending publisher, which creates the project on its first upload. At pypi.org/manage/account/publishing, under GitHub:

Field Value
PyPI Project Name parsec-html
Owner parsec-html
Repository name parsec
Workflow name release-python.yml
Environment name release

5. Put parsec-html on npm, and add its trusted publisher

Section titled “5. Put parsec-html on npm, and add its trusted publisher”

npm, too, needs the package to exist before it can trust a workflow, and a new trusted publisher has to make its first publish within 2 days or it expires. So publish a placeholder now, and add the publisher on the day you tag.

The placeholder (npm asks for your 2FA code):

Terminal window
mkdir -p "$HOME/parsec-npm-placeholder"
printf '{\n "name": "parsec-html",\n "version": "0.0.0",\n "description": "A placeholder for Parsec, the HTML parser. 0.1.0 is the first release.",\n "license": "Apache-2.0",\n "repository": { "type": "git", "url": "git+https://github.com/parsec-html/parsec.git" }\n}\n' > "$HOME/parsec-npm-placeholder/package.json"
npm login
npm publish "$HOME/parsec-npm-placeholder" --access public
rm -rf "$HOME/parsec-npm-placeholder"

On tag day, at npmjs.com/package/parsec-html/access, under Trusted Publisher, choose GitHub Actions:

Field Value
Organization or user parsec-html
Repository parsec
Workflow filename release-npm.yml
Environment name release
Allowed actions tick npm publish (the workflow publishes directly, not staged)

Or the same from the command line, with npm 11.15 or newer:

Terminal window
npm trust github parsec-html --file release-npm.yml --repo parsec-html/parsec --env release --allow-publish
Terminal window
gh variable set CRATES_PUBLISH --repo parsec-html/parsec --body true
gh variable set PYPI_PUBLISH --repo parsec-html/parsec --body true
gh variable set NPM_PUBLISH --repo parsec-html/parsec --body true
gh variable list --repo parsec-html/parsec

For 0.1.0, that’s #32: its blockers closed, and the benchmark ahead of Lexbor on every page.

Terminal window
gh issue view 32 --repo parsec-html/parsec
gh run list --repo parsec-html/parsec --branch main --workflow ci.yml --limit 1

2. Set the version, the changelog and the baseline

Section titled “2. Set the version, the changelog and the baseline”

For 0.1.0 this is done: every version is already 0.1.0. For the next one, change version in ~/Documents/GitHub/parsec/Cargo.toml ([workspace.package]), the version = "…" requirements in crates/*/Cargo.toml, bindings/python/Cargo.toml, bindings/wasm/Cargo.toml, bindings/wasm/npm/package.json and the PARSEC_VERSION lines in crates/parsec-capi/cbindgen.toml (then run the cbindgen command at its top, so include/parsec.h follows; a test fails if they disagree), and add the release to CHANGELOG.md, in a pull request like any other.

The same pull request moves conformance/baseline.json to main’s counts, from the conformance artifact of main’s latest CI run:

Terminal window
run=$(gh run list --repo parsec-html/parsec --branch main --workflow ci.yml --status success --limit 1 --json databaseId -q '.[0].databaseId')
gh run download "$run" --repo parsec-html/parsec -n conformance -D "$HOME/parsec-conformance"
jq -s 'map({key: .suite, value: {passed, failed, skipped}}) | sort_by(.key) | from_entries' "$HOME"/parsec-conformance/*.json \
> ~/Documents/GitHub/parsec/conformance/baseline.json
git -C ~/Documents/GitHub/parsec diff conformance/baseline.json
rm -rf "$HOME/parsec-conformance"

Read the diff: every count that went down is a case the release gives up, and the pull request says why. New suites appear in it as new entries.

A manual run does everything but the tag check and the publishing:

Terminal window
for w in release.yml release-python.yml release-npm.yml release-capi.yml; do
gh workflow run "$w" --repo parsec-html/parsec --ref main
done
sleep 10
gh run list --repo parsec-html/parsec --event workflow_dispatch --limit 4

Wait for all four to go green (gh run watch RUN_ID --repo parsec-html/parsec).

From an up-to-date main, with the SSH key listed in .github/allowed_signers:

Terminal window
git -C ~/Documents/GitHub/parsec switch main
git -C ~/Documents/GitHub/parsec pull --ff-only
git -C ~/Documents/GitHub/parsec -c gpg.format=ssh -c user.signingkey="$HOME/.ssh/id_ed25519.pub" tag -s v0.1.0 -m "Parsec 0.1.0"
git -C ~/Documents/GitHub/parsec -c gpg.ssh.allowedSignersFile="$HOME/Documents/GitHub/parsec/.github/allowed_signers" tag -v v0.1.0
git -C ~/Documents/GitHub/parsec push origin v0.1.0

tag -v should print Good "git" signature for …. Then watch the four runs:

Terminal window
gh run list --repo parsec-html/parsec --commit "$(git -C ~/Documents/GitHub/parsec rev-parse 'v0.1.0^{commit}')"

If the release environment has a required reviewer, each publish job waits for an approval on its run page.

The files on the release, and their provenance:

Terminal window
gh release download v0.3.0 --repo parsec-html/parsec --dir "$HOME/parsec-0.3.0"
for f in "$HOME"/parsec-0.3.0/*.crate; do
gh attestation verify "$f" --repo parsec-html/parsec \
--signer-workflow parsec-html/parsec/.github/workflows/release.yml
done
for f in "$HOME"/parsec-0.3.0/parsec-capi-*.tar.gz "$HOME"/parsec-0.3.0/parsec-capi-*.zip; do
gh attestation verify "$f" --repo parsec-html/parsec \
--signer-workflow parsec-html/parsec/.github/workflows/release-capi.yml
done

crates.io’s checksums against the release’s SHA256SUMS (the workflow checks this too):

Terminal window
for c in parsec-base parsec-js parsec-web parsec-web-core parsec-web-encoding parsec-url parsec-xpath parsec-xml parsec-web-css; do
echo "$(curl -s -A "parsec-web release" "https://crates.io/api/v1/crates/$c/0.3.0" | jq -r .version.checksum) $c-0.3.0.crate"
done | sort -k2 | diff - <(sort -k2 "$HOME/parsec-0.3.0/SHA256SUMS") && echo "crates.io matches"

Each registry, from a clean project:

Terminal window
cargo new --vcs none "$HOME/parsec-try" && cargo add --manifest-path "$HOME/parsec-try/Cargo.toml" [email protected] --features css
cat > "$HOME/parsec-try/src/main.rs" <<'EOF'
fn main() {
let doc = parsec::parse("<ul><li class=hit>one<li>two</ul>", false);
let hits = parsec::css::SelectorList::parse("li.hit").unwrap().select(&doc, doc.root());
println!("{}", doc.text(hits[0]));
}
EOF
cargo run -q --manifest-path "$HOME/parsec-try/Cargo.toml" # one
python3 -m venv "$HOME/parsec-venv" && "$HOME/parsec-venv/bin/pip" install -q parsec-web==0.3.0
"$HOME/parsec-venv/bin/python" -c 'from parsec_html import HTMLParser; print(HTMLParser("<ul><li class=hit>one<li>two</ul>").css_first("li.hit").text())' # one
mkdir -p "$HOME/parsec-npm-try" && npm install -s --prefix "$HOME/parsec-npm-try" [email protected]
(cd "$HOME/parsec-npm-try" && node --input-type=module -e 'import { parse } from "parsec-web"; console.log(parse("<ul><li class=hit>one<li>two</ul>").selectFirst("li.hit").textContent)') # one
(cd "$HOME/parsec-npm-try" && npm audit signatures)
rm -rf "$HOME/parsec-try" "$HOME/parsec-venv" "$HOME/parsec-npm-try" "$HOME/parsec-0.3.0"

Also look at docs.rs/parsec-web, which builds a few minutes after the publish, with every feature on.

  • Turn on Require trusted publishing in each crate’s settings on crates.io, so a leaked token can’t publish a version.
  • Yank the 0.0.0 placeholders, so nobody picks one by accident: cargo yank --version 0.0.0 NAME for each crate (with a token that has the yank scope), and npm deprecate [email protected] "Use 0.3.0 or later".
  • In the docs (parsec-html/website, apps/docs): the overview names the latest release, and Changelog has it under “Unreleased”. Change both, and the version anywhere a page quotes one.
  • Post the release in Discussions (Announcements), and close #32.
  • A gate fails. Nothing was built or published. The job’s summary says which suite, page or fuzz target. Fix it on main, delete the tag (as for the tag check, below) and tag the fixed commit. If a drop in a suite is meant, the baseline moves in a release pull request first.

  • The tag check fails. Nothing was published. Delete the tag (git -C ~/Documents/GitHub/parsec push origin :refs/tags/v0.1.0 and git -C ~/Documents/GitHub/parsec tag -d v0.1.0), fix what it says, and tag again.

  • A publish job fails after others succeeded. Fix the cause (usually a trusted publisher field that doesn’t match), then gh run rerun RUN_ID --failed --repo parsec-html/parsec. Versions already up are skipped.

  • The crates.io checksum check fails. crates.io has a package that isn’t the release’s: someone published by hand, or the package isn’t reproducible. Don’t yank in a hurry; compare the two with scripts/package-twice.sh at the tag first.

  • A version is wrong once it’s up. crates.io, PyPI and npm never let a version number be used twice. Yank it and release the next patch version.