Skip to content
Xerobi Icons

Publishing to pub.dev

The Flutter package: first publish by hand, then switch on automated publishing from GitHub releases.

Last updated

Package: xerobi_icons, folder packages/flutter (an icon font in six weights plus typed IconData constants).

1. Account (once)

Sign in at <https://pub.dev> with the Google account that will own the package. Optional but recommended: create a verified publisher (pub.dev → Create publisher, a domain you control, verified through Google Search Console) so the package shows a verified badge and ownership is not tied to one person. You can move the package under a publisher later (package page → Admin).

Check the name is free: <https://pub.dev/packages/xerobi_icons> should say “not found”.

2. First publish (by hand, once)

cd tooling/generator && uv sync && bun run build:all    # packages/flutter must be current
cd ../..
node scripts/first-publish.mjs pub           # dry run (flutter pub publish --dry-run)
node scripts/first-publish.mjs pub --yes     # real publish

The dry run prints the package size, any warnings, and the files it would upload. Fix warnings before the real run. The first real run opens a Google sign-in in your browser and asks for confirmation in the terminal. pub.dev limits the compressed archive size (currently 100 MB); the dry run tells you where you are. A published version is permanent: you can only retract it, not delete it, so do the dry run.

Check: <https://pub.dev/packages/xerobi_icons>. A new package takes a few minutes to get its score (“pub points”).

3. Switch on automated publishing

On the package page → Admin → Automated publishing → Enable publishing from GitHub Actions:

Field Value
Repository xerobi/xerobi-icons
Tag pattern v{{version}}
Require GitHub Actions environment leave off (or create an environment and name it here and in release.yml)

Then set the repository variable PUB_AUTOMATED to true (Settings → Secrets and variables → Actions → Variables). The pub job in release.yml is skipped until it is set.

4. What the workflow does

On a GitHub release vX.Y.Z, job pub runs flutter pub publish --force, authenticated by OIDC (no secret). It first asks pub.dev whether that version already exists and, if it does, does nothing, so the first release can safely follow your manual publish.

Rules that bite:

  • The tag must equal v + the pubspec version (the generator writes the pubspec from the root package.json; the workflow’s verify job checks the tag against that file).
  • It only works from a GitHub release / tag. A manual workflow_dispatch run has a branch as its ref and pub.dev will refuse.
  • The pubspec needs repository, description, license and a CHANGELOG.md; the generator provides them.

Common errors

Error Fix
“Version X is already published” Bump and release a new version
“not authorized to publish” in CI Automated publishing not enabled, tag pattern wrong (must be v{{version}}), repository path wrong, or not a release run
Dry run: “package too large” Trim fonts or assets in packages.py’s Flutter generator; check which weights ship
Dry run warnings about formatting Run dart format . in packages/flutter; CI already checks this
Wrong release published dart pub retract xerobi_icons --version 0.1.0 (or the Admin page), then publish a fix