Structure your GitHub repositories
Before generating SDKs with Fern, you’ll need to set up the proper GitHub repository structure to house your API definitions and SDK code so it’s intuitive for you and your users to access, maintain, and update code.
Structuring your top-level repository
- Identify or create a top-level GitHub repository where you want all of your SDK and API code to live.
- Install the Fern GitHub App on the top-level repository and all SDK repositories. Select Configure, then scroll down to Repository Access. Select Only select repositories and in the dropdown select the repository for your SDK. Click Save.
For example, your basic GitHub file structure should look something like this:
Your generators.yml
file will contain a group for each of your SDKs. Each group points
to the GitHub repository for the relevant SDK.
For example, the group
for a TypeScript SDK might look like this:
For additional examples, see Cohere’s generators.yml
file
and Vapi’s generators.yml
file.
github
section to whether Fern
should commit and release, create a pull request, or push code to a branch when
you make changes to your SDK code. See GitHub
Configuration for more
details. Structuring SDK-specific repositories
- Create a new GitHub repository called
company-<language>
(or something similar) for each of your SDKs, if you haven’t done so already. - Install the Fern GitHub App on the top-level repository and all SDK repositories. Select Configure, then scroll down to Repository Access. Select Only select repositories and in the dropdown select the repository for your SDK. Click Save.
The repository structure for a specific SDK should look similar to this:
Fern generates most of the SDK files listed in this example repository (scripts/
, src/
, tests
,
.fernignore
, etc.), including any custom code you added. You have to manually set up .github/workflows
to execute actions, like publishing SDK versions to a package repository.
For additional examples, see Cohere’s Python SDK repository and Vapi’s TypeScript SDK repository.