Skip to content

Commit 90b500c

Browse files
authored
Update GitHub Actions release workflow instructions for npm publishing page (#326)
1 parent 5e42f0e commit 90b500c

File tree

4 files changed

+70
-43
lines changed

4 files changed

+70
-43
lines changed
Binary file not shown.
62.7 KB
Loading

fern/products/sdks/overview/typescript/publishing-to-npm.mdx

Lines changed: 69 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,17 @@ groups:
162162

163163
</Steps>
164164

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.
166168

167169
<AccordionGroup>
168-
<Accordion title="Option 1: Configure authentication via GitHub Actions">
170+
<Accordion title="Release via a GitHub workflow (recommended)">
169171

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.
171173

172174
<Steps>
173-
174-
<Step title="Navigate to Actions in Settings">
175+
<Step title="Set up authentication">
175176

176177
Open your Fern repository in GitHub. Click on the **Settings** tab in your repository. Then, under the **Security** section, open **Secrets and variables** > **Actions**.
177178

@@ -182,7 +183,6 @@ Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart)
182183
You can also use the url `https://github.com/<your-repo>/settings/secrets/actions`.
183184

184185
</Step>
185-
186186
<Step title="Add secret for your npm Token">
187187

188188
1. Select **New repository secret**.
@@ -195,43 +195,70 @@ Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart)
195195
</Frame>
196196

197197
</Step>
198+
<Step title="Add secret for your Fern Token">
198199

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**.
202206

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.
207+
<Frame>
208+
<img src="assets/npm-token-secret.png" alt="NPM_TOKEN secret" />
209+
</Frame>
207210

208211
</Step>
209-
<Step title="Add token to `generators.yml`">
210-
211-
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.
212-
213-
```yaml {9}
214-
groups:
215-
ts-sdk:
216-
generators:
217-
- name: fernapi/fern-typescript-sdk
218-
version: <Markdown src="/snippets/typescript-sdk-version.mdx"/>
219-
output:
220-
location: npm
221-
package-name: name-of-your-package
222-
token: ${NPM_TOKEN}
223-
config:
224-
namespaceExport: YourClientName
225-
github:
226-
repository: your-org/your-repository
212+
<Step title="Set up a new workflow">
213+
214+
In your repo, navigate to **Actions**. Select **New workflow**, then **Set up workflow yourself**. Set up a workflow dispatch that is similar to this:
215+
216+
```yaml title=".github/workflows/publish.yml" maxLines=0
217+
name: Publish TypeScript SDK
218+
219+
on:
220+
workflow_dispatch:
221+
inputs:
222+
version:
223+
description: "The version of the TypeScript SDK that you would like to release"
224+
required: true
225+
type: string
226+
227+
jobs:
228+
release:
229+
runs-on: ubuntu-latest
230+
steps:
231+
- name: Checkout repo
232+
uses: actions/checkout@v4
233+
234+
- name: Install Fern CLI
235+
run: npm install -g fern-api
236+
237+
- name: Release TypeScript SDK
238+
env:
239+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
240+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
241+
run: |
242+
fern generate --group ts-sdk --version ${{ inputs.version }} --log-level debug
227243
```
244+
</Step>
245+
<Step title="Run your workflow">
228246

229-
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
248+
click **Run workflow**.
249+
250+
<Frame>
251+
<img src="assets/ts-sdk-release-action.png" alt="Running TS publish workflow" />
252+
</Frame>
253+
254+
Once your workflow completes, log back into npm and
255+
navigate to **Packages** to see your new release.
256+
230257
</Step>
231258
</Steps>
232259

233260
</Accordion>
234-
<Accordion title="Option 2: Configure via environment variables">
261+
<Accordion title="Release via CLI and environment variables">
235262
<Steps>
236263
<Step title="Configure npm authentication token">
237264

@@ -252,6 +279,8 @@ groups:
252279
github:
253280
repository: your-org/your-repository
254281
```
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)
255284
</Step>
256285
<Step title="Set npm environment variable">
257286

@@ -262,19 +291,17 @@ groups:
262291
```
263292

264293
</Step>
265-
</Steps>
266-
</Accordion>
267-
</AccordionGroup>
268-
294+
<Step title="Regenerate your SDK">
269295

270296

271-
## Release your SDK to npm
272-
273-
Regenerate your SDK and publish it on npm:
274-
275297
```bash
276298
fern generate --group ts-sdk --version <version>
277299
```
278300
Local machine output will verify that the release is pushed to your
279301
repository and tagged with the version you specified. Log back into npm and
280-
navigate to **Packages** to see your new release.
302+
navigate to **Packages** to see your new release.
303+
304+
</Step>
305+
</Steps>
306+
</Accordion>
307+
</AccordionGroup>

fern/products/sdks/sdks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ navigation:
3333
- page: Configuration
3434
path: ./overview/typescript/configuration.mdx
3535
slug: configuration
36-
- page: Publishing to NPM
36+
- page: Publishing to npm
3737
path: ./overview/typescript/publishing-to-npm.mdx
3838
slug: publishing
3939
- page: Adding custom code

0 commit comments

Comments
 (0)