Packaging and publishing
What the CLI package contains, the automatic publishing workflow, and the first-time setup of npm trusted publishing.
Packaging
bun run build:cli creates dist/fpd/. It bundles the CLI commands, the fixed sampling challenges, the shared algorithms, the reference bank worker, and the offline fitting modules in this repository. It copies the public reference bank, detector parameters, and tokenizer bank, and pins the versions of the installed runtime dependencies. Raw sampling records are not packaged. Sampling, enrollment, and offline retraining can run outside the repository with Node or Bun. The CLI bundles the TypeScript training modules and numerical library.
Automatic publishing
The Publish FPD CLI workflow runs on main. It starts automatically when the CLI, shared algorithms, reference data, dependencies, or release configuration change, and it also supports manual dispatch. Each build uses 0.0.<Unix time in milliseconds> as its version and publishes the latest tag. No manual version bump or Git tag is required. Release jobs run sequentially, verify a clean installation outside the repository, and check the npm tag after publishing.
First-time setup
The workflow uses npm trusted publishing (GitHub OIDC). The first-time setup requires an npm account with permission to publish lmfpd:
npm login
bun run build:cli
cd dist/fpd
npm publish --access public --tag latest
npm trust github lmfpd --repo Ikaleio/lm-detector \
--file publish-cli.yml --allow-publish --yesThe trusted publisher must allow direct npm publish. After setup, GitHub Actions needs no stored npm token. Dispatch the workflow manually once to verify the authorization before you rely on automatic releases.
SDK releases
The four SDKs share one version. To release, set version in sdk/rust/Cargo.toml and sdk/python/pyproject.toml, commit, and push a tag:
git tag sdk/v0.2.0 && git push origin sdk/v0.2.0.github/workflows/publish-sdk.yml checks the tag against both versions and runs typecheck and sdk:check. It then publishes lmfpd-sdk to npm and lmfpd to crates.io and PyPI, all with trusted publishing and no stored tokens. For Go it pushes the tag sdk/go/v0.2.0 and asks the Go module proxy for it once. Before publishing to npm and PyPI, it installs the new package in a clean environment and tries it. Versions that are already published are skipped, so you can rerun the failed jobs after a registry fails.
First-time setup: npm and crates.io allow trusted publishing only for packages that exist, so publish once by hand and then authorize the workflow. PyPI accepts a pending publisher before the first release.
| Registry | Setup |
|---|---|
| npm | After one manual publish, run npm trust github lmfpd-sdk --repo Ikaleio/lm-detector --file publish-sdk.yml --allow-publish --yes |
| crates.io | Run cargo publish once with an API token, then add the repository Ikaleio/lm-detector and workflow publish-sdk.yml under Trusted Publishing in the crate settings |
| PyPI | On your account's Publishing page, add a GitHub publisher for the project lmfpd: repository Ikaleio/lm-detector, workflow publish-sdk.yml, no environment |
SDK data mirror
The SDKs contain no reference data. At runtime they download it from https://lm.ikale.io/data/ and fall back to the mainland China mirror https://cdn.jsdmirror.com/npm/lmfpd-data@latest/. The mirror serves the npm package lmfpd-data. The package holds only bundle.json and the detector's compressed chunks, in the same layout as the website's /data/.
When the reference data, sync-data.ts, or the package script changes on main, .github/workflows/publish-data.yml rebuilds the package. If its bundle.json matches the one on npm, the workflow stops. Otherwise it loads the package through the TypeScript SDK and publishes it with trusted publishing. It then purges jsDelivr's @latest cache and warms the chunks on the mirror. JSDMirror caches @latest for a few hours; set the repository secret JSDMIRROR_API_KEY (issued after you register at cache.jsdmirror.com) and the workflow purges it as well. Until the mirror updates, users who reach only the mirror get the previous data.
The first-time setup matches the CLI's: publish once by hand, then authorize the workflow:
npm login
bun run build:data-package
cd dist/lmfpd-data
npm publish --access public --tag latest
npm trust github lmfpd-data --repo Ikaleio/lm-detector \
--file publish-data.yml --allow-publish --yesWebsite and docs
The website and docs deploy automatically through the Git integration of Cloudflare Pages. GitHub Pages is published by a manually dispatched workflow. See Deployment.
Last updated on