You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/sdks/overview/typescript/publishing-to-npm.mdx
+69-42Lines changed: 69 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,16 +162,17 @@ groups:
162
162
163
163
</Steps>
164
164
165
-
## Configure npm authentication
165
+
## Configure npm publication
166
+
167
+
Choose how you want to authenticate and publish your SDK to npm. You can use GitHub workflows for automated releases or publish directly via the CLI.
166
168
167
169
<AccordionGroup>
168
-
<Accordion title="Option 1: Configure authentication via GitHub Actions">
170
+
<Accordion title="Release via a GitHub workflow (recommended)">
169
171
170
-
Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) to automatically publish new SDK versions to npm when you push code changes.
172
+
Set up a release workflow via [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) so you can trigger new SDK releases directly from your repository.
171
173
172
174
<Steps>
173
-
174
-
<Step title="Navigate to Actions in Settings">
175
+
<Step title="Set up authentication">
175
176
176
177
Open your Fern repository in GitHub. Click on the **Settings** tab in your repository. Then, under the **Security** section, open **Secrets and variables** > **Actions**.
177
178
@@ -182,7 +183,6 @@ Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart)
182
183
You can also use the url `https://github.com/<your-repo>/settings/secrets/actions`.
183
184
184
185
</Step>
185
-
186
186
<Step title="Add secret for your npm Token">
187
187
188
188
1. Select **New repository secret**.
@@ -195,43 +195,70 @@ Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart)
195
195
</Frame>
196
196
197
197
</Step>
198
+
<Step title="Add secret for your Fern Token">
198
199
199
-
<Step title="Allow GitHub to run workflows">
200
-
201
-
Change your workflow permissions to allow GitHub to run workflows:
200
+
1. Select **New repository secret**.
201
+
1. Name your secret `FERN_TOKEN`.
202
+
1. Add your Fern token. If you don't already have one, generate one by running
203
+
`fern-token`. By default, the `fern_token` is generated for the organization
204
+
listed in `fern.config.json`.
205
+
1. Click **Add secret**.
202
206
203
-
1. Click on the **Settings** tab in your repository.
204
-
1. Under the **Code and automation** section, navigate to **Actions** > **General**.
205
-
1. Under **Actions permissions**, select **Allow all actions and reusable workflows**.
206
-
1. **Save** your settings. Now GitHub can run the actions you configure.
Add `token: ${NPM_TOKEN}` to `generators.yml` to tell Fern to use the `NPM_TOKEN` environment variable (which you just configured in your GitHub repo) for authentication when publishing to the npm registry.
When you regenerate your release, Fern will automatically create a workflow in your repository called `.github/workflows/ci.yml` that will automatically publish your release to npm. For an example, see Vapi's [npm publishing GitHub Action](https://github.com/VapiAI/server-sdk-typescript/blob/main/.github/workflows/ci.yml)
247
+
Navigate to the **Actions** tab, select the workflow you just created, and
Once your workflow completes, log back into npm and
255
+
navigate to **Packages** to see your new release.
256
+
230
257
</Step>
231
258
</Steps>
232
259
233
260
</Accordion>
234
-
<Accordion title="Option 2: Configure via environment variables">
261
+
<Accordion title="Release via CLI and environment variables">
235
262
<Steps>
236
263
<Step title="Configure npm authentication token">
237
264
@@ -252,6 +279,8 @@ groups:
252
279
github:
253
280
repository: your-org/your-repository
254
281
```
282
+
283
+
When you regenerate your release, Fern will automatically create a workflow in your repository called `.github/workflows/ci.yml` that will automatically publish your release to npm. For an example, see Vapi's [npm publishing GitHub Action](https://github.com/VapiAI/server-sdk-typescript/blob/main/.github/workflows/ci.yml)
255
284
</Step>
256
285
<Step title="Set npm environment variable">
257
286
@@ -262,19 +291,17 @@ groups:
262
291
```
263
292
264
293
</Step>
265
-
</Steps>
266
-
</Accordion>
267
-
</AccordionGroup>
268
-
294
+
<Step title="Regenerate your SDK">
269
295
270
296
271
-
## Release your SDK to npm
272
-
273
-
Regenerate your SDK and publish it on npm:
274
-
275
297
```bash
276
298
fern generate --group ts-sdk --version <version>
277
299
```
278
300
Local machine output will verify that the release is pushed to your
279
301
repository and tagged with the version you specified. Log back into npm and
0 commit comments