Publishing to npm
The six @xerobi packages: create the organization, publish once by hand, add trusted publishers, and let releases publish automatically.
Last updated
Six packages, one scope:
| Package | Folder |
|---|---|
@xerobi/icons-core |
packages/core (about 20 MB packed, 36,000 files: SVG assets, sprites, metadata, MCP server) |
@xerobi/icons-react |
packages/react |
@xerobi/icons-react-native |
packages/react-native |
@xerobi/icons-vue |
packages/vue |
@xerobi/icons-web |
packages/web |
@xerobi/icons-font |
packages/font |
1. Account, 2FA, organization (once)
- Create an account at <https://www.npmjs.com/signup>. Verify the email.
- Enable two-factor authentication (Account → Two-Factor Authentication, “Authorization and publishing”). npm requires it to publish.
- Create the scope: <https://www.npmjs.com/org/create>, name
xerobi, free plan (public packages only). The scope@xerobionly exists once that organization does. If the name is taken, the packages must move to another scope: change it intooling/generator/scripts/packages.py(search@xerobi/), the site and every guide. - Add teammates who may publish under Organization → Members.
2. Check the names are free
for p in core react react-native vue web font; do npm view @xerobi/icons-$p name 2>&1 | head -1; done
E404 means free. A name that prints back is taken by someone (hopefully you).
3. First publish (by hand, once)
cd tooling/generator && uv sync && bun run build:all && bun run test # packages/* must be current
cd ../..
npm login # opens the browser; use the 2FA code
node scripts/first-publish.mjs npm # dry run: file count and size per package, version check
node scripts/first-publish.mjs npm --yes # publishes each package that is not on npm yet
What the script does: checks every package folder exists and equals the repo version, then npm pack --dry-run for the size,
and with --yes runs npm publish --access public in each folder (scoped packages are private unless --access public).
It asks for your 2FA code per package. It skips packages that are already published, so you can re-run it after a failure.
No --provenance here: provenance only works from supported CI, so this first version has none and later ones do.
Check:
npm view @xerobi/icons-react version
mkdir /tmp/try && cd /tmp/try && npm init -y && npm i @xerobi/icons-react react
4. Switch on automated (trusted) publishing
Do this for each of the six packages, now that they exist. On npmjs.com open the package → Settings → Trusted Publisher → GitHub Actions, and enter:
| Field | Value |
|---|---|
| Organization or user | xerobi |
| Repository | xerobi-icons |
| Workflow filename | release.yml |
| Environment | leave empty |
The filename must match exactly, with no path. No token is stored anywhere: npm trusts the workflow’s identity (OIDC). It needs
npm ≥ 11.5.1, which release.yml installs, and the id-token: write permission it already has.
Then, still in each package’s settings, set Publishing access to Require two-factor authentication and disallow tokens. That closes the door on stolen tokens; trusted publishing keeps working.
Prefer a token for the very first automated run? Create a granular access token (read and write, scope @xerobi, short expiry),
save it as the repository secret NPM_TOKEN, and delete it once Trusted Publishers work.
5. What the workflow does
release.yml → job npm (one matrix job per package): downloads the freshly built package, runs npm publish --access public --provenance,
and skips a package whose exact version is already on npm. The package page then shows a provenance badge linking to the workflow run.
Common errors
| Error | Meaning and fix |
|---|---|
E403 ... You do not have permission to publish "@xerobi/..." |
You are not a member of the xerobi organization, or the scope does not exist |
E402 Payment Required |
You published without --access public; use the script |
E403 ... cannot publish over the previously published versions |
That version exists. Bump the version (npm versions are permanent) |
E404 ... 'xerobi/...' is not in this registry on npm view |
Not published yet |
EOTP |
2FA code expired; run again |
ENEEDAUTH in CI |
Trusted Publisher missing for that package, wrong workflow filename, or NPM_TOKEN not set |
Unable to authenticate in CI |
npm older than 11.5.1 (the workflow upgrades it; check the step ran) |
Size warnings on core |
Expected: 36,000 SVG files. Keep it; consumers who only want components use -react etc. |
Unpublishing: npm allows it only within 72 hours and only if nothing depends on the package. Prefer
npm deprecate @xerobi/[email protected] "use 0.1.1" and publish a fix.