Publish a public-facing SDK

GitHub Page
Merge.dev uses Fern for their SDKs

This guide will walk you through how to publish public-facing SDKs through Fern.

1

Navigate to your generators.yml

This guide assumes that you already have an initialized fern folder. If you don’t please run fern init!

Your generators.yml lives inside of the fern folder and contains all the configuration for your Fern generators.

2

Run `fern add

In order to generate the SDK, we’ll need to add the generator to your generators.yml. You can use the fern <add> command to do this.

$fern add fern-typescript-node-sdk --group ts-sdk

Once the command completes, you’ll see a new group created in your generators.yml.

1groups:
2 ts-sdk:
3 generators:
4 - name: fernapi/fern-typescript-node-sdk
5 version: 0.48.4
6 output:
7 location: local-file-system
8 path: ../sdks/typescript

Here are the latest versions of each generator.

3

Configure output location

In order to setup publishing your SDK, you’ll need to configure an output location in your generators.yml.

1groups:
2 ts-sdk:
3 generators:
4 - name: fernapi/fern-typescript-node-sdk
5 version: 0.48.4
6 output:
7 location: npm
8 package-name: imdb
9 token: ${NPM_TOKEN} # reads from environment
4

Install GitHub app

To configure the GitHub integration, you must (1) create a GitHub repository and (2) install the Fern GitHub App.

5

Configure GitHub location

Once you’ve created the GitHub repository, you must add it to your generators.yml:

TypeScript
1groups:
2 ts-sdk:
3 generators:
4 - name: fernapi/fern-typescript-node-sdk
5 version: 0.9.5
6 output:
7 location: npm
8 package-name: imdb
9 token: ${NPM_TOKEN}
10 github:
11 repository: your-org/your-repository
6

Run fern generate

At this point, you are ready to go and can run fern generate --version <version>.

Make sure that any environment variables like NPM_TOKEN are present!
7

Setup a GitHub Action

We strongly advise adding a GitHub Action to trigger SDK releases for each language. Below is an example of how you might setup a workflow_dispatch

1name: Publish Python SDK
2
3on:
4 workflow_dispatch:
5 inputs:
6 version:
7 description: "The version of the Python SDK that you would like to release"
8 required: true
9 type: string
10
11jobs:
12 release:
13 runs-on: ubuntu-latest
14 steps:
15 - name: Checkout repository
16 uses: actions/checkout@v4
17
18 - name: Install Fern CLI
19 run: npm install -g fern-api
20
21 - name: Release Python SDK
22 env:
23 FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
24 PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
25 run: |
26 fern generate --group python-sdk --version ${{ inputs.version }} --log-level debug

Once these actions are merged in, you can simply release your SDK by navigating to the actions tab:

GitHub Page
Built with