Publishing
Early access
The CLI generator is in early access. Reach out to get started.
Publish your generated CLI to npm. After following the steps on this page, each tagged release builds cross-platform binaries and publishes them automatically. Homebrew and GitHub Releases distribution are coming soon. To keep generation on your own infrastructure, you can self-host the generator instead of using Fern’s cloud.
This page assumes that you have:
- An initialized
fernfolder withgenerators.ymlconfigured for the CLI generator. See Quickstart. - An existing GitHub repository for the generated CLI source, with the Fern GitHub App installed on it.
Configure output location
Configure GitHub publishing
Fern publishes your CLI via GitHub Actions. Configure your GitHub repository and publishing mode:
The repository owner is independent of your Fern organization (the --organization value passed to fern init). Point it at the GitHub user or organization that owns the target repository.
Configure authentication
Choose how to authenticate with npm when publishing.
OIDC authentication (Recommended)
OIDC-based publishing (trusted publishing) is the most secure option. npm trusts your GitHub repository to publish directly — no tokens to manage.
Create the packages on npm
The CI workflow publishes one launcher package and one package per platform. For a package named @myorg/my-cli, that’s:
OIDC can’t perform a package’s first publish; npm requires a package to exist before you can add a trusted publisher. Run the following script to create and publish a placeholder for each package:
Authorize your repository on npmjs.com
Configure trusted publishing on npmjs.com. Repeat this for every package listed above — an OIDC run fails on any package that has no trusted publisher.
- Open the package page on npmjs.com and go to the Settings tab
- Find the Trusted Publisher section and click Add trusted publisher
- Select GitHub Actions as your provider
- Fill in:
- Organization or user: Your GitHub username or organization
- Repository: Your CLI repository name (e.g.
my-cli) - Workflow filename:
ci.yml - Environment name: Leave blank
- Under Allowed actions, select Allow
npm publish
Token-based authentication
Generate an npm token
- Log into npmjs.com
- Click your profile picture and select Access Tokens
- Click Generate New Token and create a granular access token
- Give it Read and Write access to All packages
- Save your token securely
Publish your CLI
How you trigger a publish depends on your mode:
- In
releasemode,fern generate --group clicommits the updated source and tags a release. The tag triggers the CI workflow (no manual release step). - In
pull-requestmode,fern generate --group cliopens a PR. Merge it, then create a GitHub release with a version tag (e.g.v1.0.0) to trigger publishing.
The CI workflow then builds binaries for all platforms and publishes to npm.
Build targets
The CI workflow produces statically linked binaries for:
The npm package wraps the native binary with a Node.js launcher. Platform-specific optional dependencies ensure only the correct binary downloads at install time.
Install instructions for users
After publishing, direct users to install with npm: