Self-hosted SDK versioning
Self-hosted SDK versioning
Enterprise feature
This feature is available only for the Enterprise plan. To get started, reach out to support@buildwithfern.com.
When self-hosting, your pipeline picks the version number for each SDK release. Unlike cloud generation, self-hosted setups need to compute the next version themselves.
The CLI exposes two workflows for this. Both can be wired into the same generation pipeline:
--version AUTOis the recommended approach. Fern classifies the change against the full SDK output — so changes driven bygenerators.ymlsettings, a generator version bump, or a CLI version bump are reflected in the version it picks — and writes the changelog entry, PR description, and conventional-commit message for you. This is also the path that continues to receive improvements.fern ir+fern diffis the deterministic alternative. It compares the intermediate representation (IR) of your API spec and returns only the computed bump and next version. Because the diff is over the spec alone, it doesn’t account for SDK-implementation changes that come fromgenerators.ymlconfiguration, generator version, or CLI version — if any of those move, you’ll need to bump the version yourself. The rest of the release artifacts (changelog, PR description, commit message) are also yours to write. Use this flow when you need explicit control over how the version number is derived, or when you can’t depend on an external LLM provider.
--version AUTO (recommended)
Pass --version AUTO to fern generate and Fern analyzes the diff between the previous and current SDK output, classifies the change as MAJOR, MINOR, or PATCH, and applies the next semantic version to the generated package. The same analysis also produces:
- A changelog entry describing what changed
- A PR description summarizing the release
- A conventional commit message
--version AUTO requires:
- A
FERN_TOKENfor organization verification (same as all self-hosted generation). - A GitHub output configured in
generators.yml, since the pipeline pushes the version bump and changelog back to the SDK repo.
Set provider credentials
Export the matching API key so the Fern CLI can call the provider:
OPENAI_API_KEYfor OpenAIANTHROPIC_API_KEYfor Anthropic- Standard AWS credentials (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION) for AWS Bedrock
The diff is sent to the provider’s API using your credentials — Fern’s infrastructure is not involved in the analysis.
Deterministic versioning with fern ir + fern diff
If you’d rather derive the version number yourself, use the fern ir and fern diff commands to compute the bump from your API definition. This flow has no LLM dependency: fern diff walks the intermediate representation (IR) of both specs and returns a deterministic result.
The workflow has three steps:
Generate the previous IR
Check out the spec as it was at the last SDK generation and write its IR to disk:
Pass --api <name> if your project defines multiple APIs.
Diff the two IRs
Run fern diff with --from-version set to the SDK’s current version. When --from-version is provided, the command prints a JSON object containing the computed bump and the next version:
bump is one of major, minor, patch, or no_change. Pass nextVersion to fern generate to release that exact version:
CLI v1
CLI v2
fern diff exits with a non-zero status when the computed bump is major. This makes it easy to gate breaking changes on a manual review step in CI.
Wiring fern ir + fern diff into CI
The non-obvious part is reproducing the IR for the previous spec. Each generated SDK records the config repo commit it was generated from in .fern/metadata.json:
originGitCommit is the SHA in the config repo that produced the SDK at its current version. Check that commit out, run fern ir, then switch back to HEAD and run fern ir again to produce both inputs to fern diff.
Example: GitHub Actions workflow
The following snippet runs in the config repo on every push to main and computes the next version for a Python SDK whose originGitCommit and sdkVersion are read from the SDK repo:
fetch-depth: 0 on the checkout step is required so the runner has the history needed to check out originGitCommit. Replace the metadata-fetch step with whatever mechanism gives your pipeline access to the SDK repo’s .fern/metadata.json (a checkout of the SDK repo, a release artifact, an internal API, and so on).